I'm trying to listen to route changes via event. I read somewhere to use the history package:
import history from 'history/browser';
// Listen for changes to the current location.
const unlisten = history.listen(({ location, action }) => {
console.log(action, location.pathname, location.state);
});
Unluckily as I call the history api I get this error:
ReferenceError: Can't find variable: document
Which is pretty obvious, as I'm not in a web-browser. Then my question is:
How can I listen/intercept/block routes change from inside a component in react-native?