Skip to content

Instantly share code, notes, and snippets.

@cellog
Created January 14, 2017 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cellog/5661e794b4491c4b1fcd9fb9c3904922 to your computer and use it in GitHub Desktop.
Save cellog/5661e794b4491c4b1fcd9fb9c3904922 to your computer and use it in GitHub Desktop.
declarative routes with react-router
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