Skip to content

Instantly share code, notes, and snippets.

@mjackson
Created November 2, 2016 19:35
Show Gist options
  • Save mjackson/8b380f12df309aa00d0f278b1f0a5119 to your computer and use it in GitHub Desktop.
Save mjackson/8b380f12df309aa00d0f278b1f0a5119 to your computer and use it in GitHub Desktop.
Nested ternaries work like if/else if/else for JSX
const element = (
<div>
{currentPage === 'signin' ? (
<SignInPage/>
) : currentPage === 'welcome' ? (
<WelcomePage/>
) : currentPage === 'about' ? (
<AboutPage/>
) : (
<DefaultPage/>
)}
</div>
)
@gustavo-depaula
Copy link

You're a monster

@abhinavjonnada82
Copy link

👏🏻

@richard457
Copy link

Good stuff bro!

@curtvict
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment