-
Notifications
You must be signed in to change notification settings - Fork 84
Routing
Chris edited this page Mar 24, 2016
·
2 revisions
This page glances over the different possible types of routing.
From your freshly created project run:
npm install --save react-router
In index.js import Router, Route and browseHistory from react-router
and set up your routes:
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { Router, Route, browserHistory } from 'react-router';
import configureStore from './stores';
import App from './containers/App';
const store = configureStore();
render(
<Provider store={store}>
<Router history={browserHistory}>
<Route path="/" component={App}>
<Route path="foo" component={App} />
<Route path="bar" component={App} />
</Route>
</Router>
</Provider>,
document.getElementById('app')
);
You now have the following three routes:
- /
- /foo
- /bar
they will all load the main container.