react-switch-case
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/react-switch-case package

1.5.1 • Public • Published

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

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i react-switch-case

    Weekly Downloads

    475

    Version

    1.5.1

    License

    MIT

    Unpacked Size

    7.5 kB

    Total Files

    7

    Last publish

    Collaborators

    • alexsergey