import {
HashRouter,
Switch,
Route,
Redirect,
useHistory
} from 'react-router-dom'
function App () {
return (
<HashRouter>
<Switch>
<Route
path="/"
component={Homepage}
exact />
<Route
path="/admin"
component={() => <div>Admin page</div>} />
<Redirect
from="*"
to="" />
</Switch>
</HashRouter>
)
}
function Homepage ({ history, location, match }) {
// Homepage has the props from its "Route" parent.
return (
<RedirectButton />
)
}
function RedirectButton () {
// react-router-dom provides us with useHistory(), useLocation() and useRouteMatch() hooks
const history = useHistory()
const handleRedirect = () => {