Skip to content

qin20/rc-if-else

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
秦缘斌
Mar 23, 2021
38c77ea · Mar 23, 2021

History

22 Commits
Mar 23, 2021
Feb 27, 2019
Feb 27, 2019
Feb 27, 2019
Feb 27, 2019
Feb 27, 2019
Mar 23, 2021
Mar 23, 2021
Feb 27, 2019
Feb 27, 2019
Mar 23, 2021
Mar 23, 2021
Mar 23, 2021
Mar 23, 2021

Repository files navigation

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.