Created
January 14, 2017 06:37
-
-
Save cellog/5661e794b4491c4b1fcd9fb9c3904922 to your computer and use it in GitHub Desktop.
declarative routes with react-router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Router from 'react-router' | |
import Route from 'react-router' | |
// import the components | |
import App from './App' | |
import Dashboard from './Dashboard' | |
import About from './About' | |
import Inbox from './Inbox' | |
import Message from './Message' | |
// example from https://github.com/ReactTraining/react-router/blob/master/docs/guides/RouteConfiguration.md | |
render(( | |
<Router> | |
<Route path="/" component={App}> | |
<IndexRoute component={Dashboard} /> | |
<Route path="about" component={About} /> | |
<Route path="inbox" component={Inbox} /> | |
{/* Use /messages/:id instead of /inbox/messages/:id */} | |
<Route component={Inbox}> | |
<Route path="messages/:id" component={Message} /> | |
</Route> | |
</Route> | |
</Router> | |
), document.body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment