rc-if-else

    1.2.1 • Public • Published

    rc-if-else

    React conditional rendering

    NPM version build status Test coverage gemnasium deps npm download

    install

    rc-if-else

    Usage

    import { If, Elif, Else } from 'rc-if-else';
    ...
    
    render(){
      ...
        // if `condition` is `true`, show `Title`, else show nothing.
        <If condition={condition} >
            <h1>Title</h1>
        </If>
    
        // if `condition` is `true`, show `Title1`, else show `Title2`.
        <If condition={condition} >
            <h1>Title1</h1>
            <Else><h1>Title2</h1></Else>
        </If>
    
        // if `condition1` is `true`, show `Title1`
        // else if `condition2` is `true`, show `Title2`
        // if all condition failed. show `Title3`
        <If condition={condition1} >
            <h1>Title1</h1>
            <ElIf condition={condition2}><h1>Title2</h1></ElIf>
            <Else><h1>Title3</h1></Else>
        </If>
    }

    License

    rc-if-else is released under the MIT license.

    Install

    npm i rc-if-else

    DownloadsWeekly Downloads

    98

    Version

    1.2.1

    License

    MIT

    Unpacked Size

    16.7 kB

    Total Files

    6

    Last publish

    Collaborators

    • footreel