react-switch-case
v1.5.1
Published
Little switch-case React component to render nested components.
Downloads
1,439
Maintainers
Readme
React Switch Case
Little switch-case React component to render nested components.
Usage
Step 1:
npm install react-switch-case -save
Step 2:
import Switch, { Case, Default } from 'react-switch-case';
Step 3:
const componentShow = 'component1';
<Switch condition={componentShow || (value) => compare(value)}>
<Case value="component1">
<span>Component 1</span>
</Case>
<Case value="component2">
<span>Component 2</span>
</Case>
<Default>
<span>Nothing!</span>
</Default>
</Switch>
License
MIT