Last active
November 28, 2018 16:55
-
-
Save mxdi9i7/b3f27885c0b99c360580c4ba6d134665 to your computer and use it in GitHub Desktop.
Router example
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'; | |
import { BrowserRouter as Router, Route } from 'react-router-dom'; | |
import LandingPage from './pages/Landing'; | |
import AboutPage from './pages/About'; | |
import LocationsPage from './pages/Locations'; | |
export const routes = [ | |
{ | |
path: '/', | |
component: LandingPage, | |
}, | |
{ | |
path: '/about', | |
component: AboutPage, | |
}, | |
{ | |
path: '/locations', | |
component: LocationPage, | |
}, | |
] | |
class App extends Component { | |
render() { | |
return ( | |
<Router> | |
<div> | |
{ | |
routes.map(route => ( | |
<Route exact path={route.path} component={route.component} /> | |
)) | |
} | |
</div> | |
</Router> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment