Created
December 29, 2015 16:45
-
-
Save dallonf/c1139d7b0c469e09bc0d to your computer and use it in GitHub Desktop.
Conditional JSX
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
function render1() { | |
return ( | |
<div> | |
{ templates.length | |
? null | |
: <div>Nothing to see here, move along...</div> | |
} | |
</div> | |
); | |
} | |
function render2() { | |
return ( | |
<div> | |
{ !templates.length && | |
<div>Nothing to see here, move along...</div> | |
} | |
</div> | |
); | |
} | |
function render3() { | |
var emptyElement; | |
if (!templates.length) { | |
emptyElement = <div>Nothing to see here, move along...</div>; | |
} | |
return ( | |
<div> | |
{emptyElement} | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment