Skip to content

Instantly share code, notes, and snippets.

@mxdi9i7
Last active November 28, 2018 16:55
Show Gist options
  • Save mxdi9i7/b3f27885c0b99c360580c4ba6d134665 to your computer and use it in GitHub Desktop.
Save mxdi9i7/b3f27885c0b99c360580c4ba6d134665 to your computer and use it in GitHub Desktop.
Router example
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