Skip to content
This repository has been archived by the owner on Sep 3, 2020. It is now read-only.
/ react-subrouter Public archive

React-router style subrouting system. When you need to change views without changing the URL

License

Notifications You must be signed in to change notification settings

TransferGo/react-subrouter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-subrouter

When you need to change views without changing the URL.

SubRouted Components can be in any part of your application.

There can be multiple SubRouters

API is closely aligned with react-router's (SubLink, SubRouteHandler, etc...)

Usage

Request Libraries

  import React from 'react';
  import {SubRoute, SubRouter, SubLink, SubRouteHandler} from 'react-subrouter';

Define SubRoutes

  var routes = (
    <SubRoute handler={Modal}>
      <SubRoute name="deposit" handler={Deposit}>
        <SubRoute name="card" handler={Card}/>
        <SubRoute name="bank" handler={Bank}/>
      </SubRoute>
      <SubRoute name="status" handler={Status}/>
      <SubRoute name="info" handler={Info}/>
    </SubRoute>
  };

Build a new SubRouter

    class Index extends SubRouter {
        constructor(props, state){
            super(props, state, routes, 'card');
        }
    }

Start building nested SubRoutes

export default class extends React.Component{
    render() {
        return (
            <div className="modal">
                <div className="tabs">
                    <SubLink to="status" className="tab three">Status</SubLink>
                    <SubLink to="deposit" className="tab three">Deposit</SubLink>
                    <SubLink to="info" className="tab three">Info</SubLink>
                </div>
                <SubRouteHandler />
            </div>
        );
    }
}

About

React-router style subrouting system. When you need to change views without changing the URL

Resources

License

Stars

Watchers

Forks

Packages

No packages published