react-if-else

1.1.1 • Public • Published

React If/Else

build status npm version

Render blocks of components using a conditional, and supply to display other blocks. Also supports using conditions to display blocks (you may consider using React-Cond instead for this case).

Usage

Install this package to your project.

Use CommonJS:

var If = require('react-if-else').If;
var ElseIf = require('react-if-else').ElseIf;
var Else = require('react-if-else').Else;
 
var YourComponent = React.createClass({
  render: function () {
    <div>
      <If cond={true} className="my-conditions">
        If true~~~
        <h2>彼女さん募集中</h2>
      <ElseIf cond={false} className="my-conditions-else-if"/>
        ElseIf true~~~
        <h4>逢いたくなったらまぶたを閉じる</h4>
      <Else className="my-conditions-else"/>
        If false~~~
        <h3>出会いの数だけで別れは増える</h3>
      </If>
    </div>
  }
});

Demo

JSFiddle: http://jsfiddle.net/tkpx7L6a/

/react-if-else/

    Package Sidebar

    Install

    npm i react-if-else

    Weekly Downloads

    2

    Version

    1.1.1

    License

    MIT

    Last publish

    Collaborators

    • chinesedfan
    • kimagure