I have a specific route for a single page application that I want to cause the page to completely reload whenever the user enters or leaves this route.
<Route
key={routeKeyGen()}
path="/example"
component={Example}
onEnter={onExampleRoute}
/>
I tried to do this by setting up onEnter
to refresh the browser page:
const onExampleRoute = () => window.location.reload();
I quickly realized this was ridiculous when the page kept reloading over and over again. I don't think this handles when leaving the route, either.
Edit Here is the React Router v3 API for Route
: https://github.com/ReactTraining/react-router/blob/v3/docs/API.md#route
Edit 2: There is an onLeave
in the React Router v3 API for Route
: https://github.com/ReactTraining/react-router/blob/v3/docs/API.md#onleaveprevstate