Skip to content
Chris edited this page Mar 24, 2016 · 2 revisions

Routing

This page glances over the different possible types of routing.

react-router

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.

Clone this wiki locally