Created
November 1, 2017 14:49
-
-
Save eddyw/26b677853ce319d82a49b10489dd15da to your computer and use it in GitHub Desktop.
Suck less at React (utilities #1): Switch Components
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
<section> | |
<SwitchIf test={this.props.section}> | |
<SwitchIf equals={1} test={this.props.isUserLogged}> | |
<SwitchWhen equals={true} render={<SectionUserLogged />} /> | |
<SwitchWhen equals={false} render={<SectionUserNotLogged />} /> | |
</SwitchIf> | |
<SwitchIf equals={2} test={this.props.isUserAdmin}> | |
<SwitchWhen equals={true} render={<SectionDashboard />} /> | |
</SwitchIf> | |
<SwitchWhen equals={3} render={<SectionAbout />} /> | |
<SwitchWhen equals={4} render={<SectionExample />} /> | |
</SwitchIf> | |
</section> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment