Created
December 9, 2022 07:14
-
-
Save solancer/7151ce392e9cd7f85a8af94184b61362 to your computer and use it in GitHub Desktop.
React conditional rendering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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