Skip to content

Instantly share code, notes, and snippets.

@JulienPradet
Created September 13, 2016 17:33
Show Gist options
  • Save JulienPradet/276d57eafeedac77357a004989c5ca1e to your computer and use it in GitHub Desktop.
Save JulienPradet/276d57eafeedac77357a004989c5ca1e to your computer and use it in GitHub Desktop.
React Router v4 : Declaring matches without polluting the actual rendering.
const BasicExample = () => (
<Router>
<div>
<Menu />
<RoutedContent />
</div>
</Router>
)
const Menu = () => (
<ul>
<li><Link to="/">Home</Link></li>
<li><Link to="/about">About</Link></li>
<li><Link to="/topics">Topics</Link></li>
</ul>
)
const RoutedContent = () => (
<Match exactly pattern="/" component={Home} />
<Match pattern="/about" component={About} />
)
const Home = () => (
<div>
<h2>Home</h2>
</div>
)
const About = () => (
<div>
<h2>About</h2>
</div>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment