import {Router, Route, hashHistory} from 'react-router' //es6
var Router = require('react-router').Router //es5
var Route = require('react-router').Route //es5
var hashHistory = require('react-router').hashHistory //es5
Inside the app.js render method, replace your exisiting component with the Router component as such:-
React Router Tutorial
Installation Steps
npm i react-router --save
Navigate to app.js or route js file
Inside the app.js render method, replace your exisiting component with the Router component as such:-
Add another Route
Add additional components for which you want to add routes for
Now visit
hostname:3000/#/about
&hostname:3000/#/contact
to view the additional pathsNavigate with Link
Add a link to an
element
Now add a
link
element to link to a routeYour
h2
tag will now navigate you to About component*###### You cannot pass down a string, you have to pass an object with pathname as found in example: - http://stackoverflow.com/questions/30115324/pass-props-in-link-react-router
Nested Routes