react-switch-path

0.0.2 • Public • Published

react-switch-path

Switch component to render React component like switch statement based on object path availability

API

import { Switch, Case, Default } from 'react-switch-path';
 
const obj = {
  propB: {
    propC: {
      id: 123
    }
  }
};
 
const app = (
  <Switch object={obj}>
    <Case path='propA' component={ComponentA}/>
    <Case path='propB' component={ComponentB}>
      <Case path='propC' component={ComponentC}/>
    </Case>
    <Default component={ComponentD}/>
  </Switch>
);
 
render(app, document.getElementById('app'));

Above will render ComponentB with ComponentC passed as children props of ComponentB. Also ComponentC will receive {id: 123} as it's props.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.2
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.2
    0
  • 0.0.1
    0

Package Sidebar

Install

npm i react-switch-path

Weekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • daiweilu