React Router’s HashRouter redirects to
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import React from 'react'; import { Route, Router } from 'react-router-dom'; import { createHashHistory } from 'history'; const Root = () => <div>Root route</div>; export default class App extends React.Component { history = createHashHistory({ basename: "", // The base URL of the app (see below) hashType: "slash", // The hash type to use (see below) // A function to use to confirm navigation with the user (see below) getUserConfirmation: (message, callback) => callback(window.confirm(message)), }); render() { return ( <Router history={this.history}> <div>Router <Route exact path="/" component={Root} /> </div> </Router> ); } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.