Last active
October 6, 2019 09:00
-
-
Save HarisSpahija/17cc213a61c8bb985a24b10c3bfd8828 to your computer and use it in GitHub Desktop.
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 at the top of the page | |
import { | |
BrowserRouter as Router, | |
Link, | |
Route | |
} from "react-router-dom"; | |
render() { | |
const { pages } = this.state; | |
return ( | |
<Router> | |
<Fragment> | |
{/* Links */} | |
<div class="topnav"> | |
{pages.map((page, index) => { | |
return <Link to={page.slug}>{page.slug}</Link>; | |
})} | |
</div> | |
{/* Routing */} | |
{pages.map((page, index) => { | |
return ( | |
<Route | |
exact | |
key={index} | |
path={`/${page.slug}`} | |
render={props => ( | |
<ExamplePage {...props} page={page} /> | |
)} | |
/> | |
); | |
})} | |
</Fragment> | |
</Router> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment