rc-if-else
v1.2.1
Published
conditional rendering for react components
Downloads
103
Maintainers
Readme
rc-if-else
React conditional rendering
install
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.