Conditionally Rendering React Components with an HOC
Conditional rendering in React is pretty straightforward and we do it everywhere. In some cases, though, a tiny abstraction can clean up our code and keep us from repeating ourselves. Here’s a simple Higher Order Component (HOC) for conditionally rendering a component or fragment if-and-only-if it has children.