Created
May 14, 2019 10:56
-
-
Save hisk/819abefd4153f487e3b2084755473052 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 React from "react"; | |
import { BrowserRouter as Router, Route } from "react-router-dom"; | |
import routes from "./routes"; | |
import withTracker from "./withTracker"; | |
import "bootstrap/dist/css/bootstrap.min.css"; | |
import "./shards-dashboard/styles/shards-dashboards.1.1.0.min.css"; | |
import { DefaultLayout } from "./layouts"; | |
// This acts as the 404 Error route component. | |
const NoMatch = () => { | |
return <DefaultLayout> | |
<p>Nothing found</p> | |
</DefaultLayout> | |
} | |
export default () => ( | |
<Router basename={process.env.REACT_APP_BASENAME || ""}> | |
<div> | |
{routes.map((route, index) => { | |
return ( | |
<Route | |
key={index} | |
path={route.path} | |
exact={route.exact} | |
component={withTracker(props => { | |
return ( | |
<route.layout {...props}> | |
<route.component {...props} /> | |
</route.layout> | |
); | |
})} | |
/> | |
); | |
})} | |
<Route component={NoMatch} /> {/* Make sure to register it at the bottom */} | |
</div> | |
</Router> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment