Skip to content

Instantly share code, notes, and snippets.

@dallonf
Created December 29, 2015 16:45
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 dallonf/c1139d7b0c469e09bc0d to your computer and use it in GitHub Desktop.
Save dallonf/c1139d7b0c469e09bc0d to your computer and use it in GitHub Desktop.
Conditional JSX
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