I have a react app that uses react-router
I want to create a route that is matched if no other route is matched, which is pretty straight forward. However I want to pass the exact route that was called to my child component. In the following code if the route was let's say /someNonMatchedRoute
I want to pass this info to the Redirect
component.
function App() {
return (
<Provider store={store}>
<div className="App">
<Router>
<Navigation />
<Switch>
<Route path="/login">
<Login />
</Route>
<Route path="/*">
<Redirect /> // I want to pass "someNonMatchedRoute" to this component
</Route>
</Switch>
</Router>
</div>
</Provider >
);
}
How would I go about doing that?