Answer the question
In order to leave comments, you need to log in
How to implement multiple routers in a React app?
The page has a sidebar with content to the right of it. When switching links in the sidebar, the content changes, everything is ok with that.
All this is in the #root block. Here is the router code:
...
render(
<Router history={browserHistory}>
<Route component={Sidebar}>
<Route path="/" component={Home}/>
<Route path="/books" component={Books}/>
<Route path="/about" component={About}/>
</Route>
</Router>,
document.getElementById('root')
...
);
...
<Router history={browserHistory}>
<Route component={Topbar}>
<Route path="/add-book" component={AddBook}/>
</Route>
</Router>,
document.getElementById('topbar')
...
...
<li><Link to="/add-book" activeClassName="active">Add Book</Link></li>
...
Answer the question
In order to leave comments, you need to log in
I would make the sidebar and topbar already inside the page component, and not part of the router.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question