react-browser-router

2.1.2 • Public • Published

A Router wrapper for react-router, it allows you to create multiple Routers sharing the same history.

Install

npm install --save react-browser-router

Example

import React, { Component } from "react";
import { render } from "react-dom";
import { 
    BrowserRouter, 
    Route, 
    Link
} from "react-browser-router";
import Home from "./components/Home";
import About from "./components/About";
import Nav from "./components/Nav";
 
class NavComponent extends Component {
    render() {
        return (<BrowserRouter>
            <div>
                <Nav />
            </div>
        </BrowserRouter>);
    }
}
 
class ViewComponent extends Component {
    render() {
        return (<BrowserRouter>
            <div>
                <Link to="/">Home</Link>
                <Link to="/about">About</Link>
 
                <Route path="/" component={Home} />
                <Route path="/about" render=(props) => (<About {...props} />) />
            </div>
        </BrowserRouter>);
    }
}
 
render(<ViewComponent />, viewElement);
render(<NavComponent />, navElement);
 

Readme

Keywords

Package Sidebar

Install

npm i react-browser-router

Weekly Downloads

128

Version

2.1.2

License

ISC

Unpacked Size

17.8 kB

Total Files

7

Last publish

Collaborators

  • junhua