node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org ยป

react-view-switch

react-view-switch

What is this?

It is simple component for switching subcomponents. It takes children and id of a view and render only one component at a time. It can be used as building block for routers, steppers, tabs etc.

Installation

npm install react-view-switch --save

Usage

For use with es6 modules

import React from 'react';
import render from 'react-dom';
import { Switch, View } from 'react-view-switch';
 
render((
    <Switch current="first-view"}>
        <View name="first-view">
          <Component/>
        </View>
        <View name="second-view">
          <Component/>
        </View>
    </Switch>
    ), 
    'your-root-element'
);

Examples

For examples just run npm script

npm run examples

and go to http://localhost:8000

License

MIT, see LICENSE.md for details.