Created
October 16, 2018 10:32
-
-
Save MeetMartin/34ae1d952ff62c22cd95edf3585f3b56 to your computer and use it in GitHub Desktop.
This file contains hidden or 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, Link } from 'react-router-dom'; | |
import Routes from './Routes'; | |
/** | |
* Turns URL path into router basename by removing everything after the last slash | |
* @param {string} path URL path, probably window.location.pathname | |
* @returns {string} final basename | |
*/ | |
const getBasename = path => path.substr(0, path.lastIndexOf('/')); | |
/** | |
* Base Template component holding the basic web application | |
* @returns {JSX} | |
*/ | |
const App = () => ( | |
<Router basename={getBasename(window.location.pathname)}> | |
<main> | |
<Routes /> | |
</main> | |
</Router> | |
); | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment