npm.io
0.0.3 • Published 10 years ago

jsx-switch

Licence
MIT
Version
0.0.3
Deps
2
Vulns
0
Weekly
0
Stars
8

jsx-switch

Simple switching for React JSX

Found a bug? Got a feature request? Submit an issue!

Installation

Install locally.

$ npm install jsx-switch --save

Requires React 15.0.0 or later.

Usage

import { Switch, Case, Default } from 'jsx-switch';

function MyComponent() {
  return (
    <Switch>
      <Case expr={...}>
        <Component1 />
      </Case>
      <Case expr={...}>
        <Component2 />
      </Case>
      <Case expr={...}>
        <Component3 />
      </Case>
      <Default>
        <Component4 />
      </Default>
    </Switch>
  );
}

Keywords