🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

react-switch-path

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-switch-path

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

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

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.

Keywords

reactjs

FAQs

Package last updated on 27 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts