Created
January 14, 2017 08:02
-
-
Save cellog/df4422c48fd065afcc24f8dc3af336ce to your computer and use it in GitHub Desktop.
react-router with nested routes
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 React, { Component } from 'react' | |
export default class Inbox extends Component { | |
render() { | |
return ( | |
<div> | |
<h2>Inbox</h2> | |
{this.props.children || "Welcome to your Inbox"} | |
</div> | |
) | |
} | |
} |
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
export default () => <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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment