renderif
Render. If. The world's simplest React component.
Installation
Let's quickly get this out of the way. How do I get your aweome code?
$ npm i --save renderif
What problem does it solve?
With renderif
you can stay within JSX without context switching.
This will render This will NOT
OK, so you would never actually code with boolean literals like that, but you get the picture.
Here is more of a real life example:
Rest of my component here
if/then/else? Sure, why not?
renderif
also supports the more concise if
/then
and the if
/then
/else
syntax shown below.
Note that in this pattern, children
is unused.
This will render }/> Rest of my component here
This will render } else={ This will NOT }/> Rest of my component here
Live Example
You can see a live example running here on codesandbox.