react-conditional-attribute
A dead simple utility for conditionally render jsx attributes
Install
Install with npm or Bower
npm install react-conditional-attribute
Use with node.js, browserify or webpack:
var attr = ;var isActive = true;; // => 'enable' //the same result with; // => 'enable'
Usage
very simple to use
; const Hello = <div className=; >hello world</div>; ReactDom;
if you want to render a litte bit complecated condition see below.
const Hello = <div someAttribute=>hello world</div>;
attr
function would return the first matched if
condtion or the first value in else
field if nothing match.
mote: you can put as much as conditions that you want, cheers.
thank for reading & happy coding.
License
MIT. Copyright (c) 2017 Minh Luc van.