Skip to content

Instantly share code, notes, and snippets.

@solancer
Created December 9, 2022 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save solancer/7151ce392e9cd7f85a8af94184b61362 to your computer and use it in GitHub Desktop.
Save solancer/7151ce392e9cd7f85a8af94184b61362 to your computer and use it in GitHub Desktop.
React conditional rendering
export const RenderIf = ({ children, when }) => {
return when ? children : null
}
import RenderIf from '../components/RenderIf'
let userLoggedIn = false
<RenderIf when={userLoggedIn}>
<UserProfile />
</RenderIf>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment