A simple react component for conditional rendering without ternary expression;
Install:
npm install react-simple-if
Use:
import If from 'react-simple-if';
const foo = true;
// render hello world
<If exp={foo} />
<p>Hello world<p>
</If>
// Does not render hello world
<If exp={!foo} />
<p>Hello world<p>
</If>
Props:
Props | Type | Description |
---|---|---|
exp | boolean | boolean to control children's renderability |