react-renderif
Installation
npm install react-renderif
Usage
var React = require('react');
var RenderIf = require('react-renderif');
<RenderIf exists={existsVariable}>
<h1>Rendered</h1>
</RenderIf>
<RenderIf notExists={existsVariable}>
<h1>Rendered</h1>
</RenderIf>
<RenderIf isTrue={trueVariable}>
<h1>Rendered</h1>
</RenderIf>
<RenderIf isFalse={falseVariable}>
<h1>Rendered</h1>
</RenderIf>
<RenderIf expression={1 === 1}>
<h1>Rendered</h1>
</RenderIf>
<RenderIf callback={function() { return 1 === 1; }}>
<h1>Rendered</h1>
</RenderIf>
Custom Matchers
react-renderif allows you to create a custom wrapper component with a callback prebound.
This callback will be passed a property
prop that can be used if you desire.
var React = require('react');
var RenderIf = require('react-renderif');
var RenderIfFoo = RenderIf.createCustomMatcher(function(property) {
return property === 'foo';
});
<RenderIfFoo property={'foo'}>
<h1>Rendered</h1>
</RenderIfFoo>
Testing / Building / Contributing
npm test
npm install
npm run build