Created
September 13, 2016 17:33
-
-
Save JulienPradet/276d57eafeedac77357a004989c5ca1e to your computer and use it in GitHub Desktop.
React Router v4 : Declaring matches without polluting the actual rendering.
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
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