I have three react-router-dom applications and I want to save browser log data from another my library which is built by node.
So how to catch react router change event from outside application??
The dependency is like this.
[A app + Logging Manager app], [B app + Logging Manager app]. [C app + Logging Manager app]
I already tried winodw.onpopstate
, npm History
.. but It doesn't work;;
[A App] [B App] [C App]
watching A,B,C router change event from outside
[Logging Manager App]
send logs with api call!!
here is my Logging Manager sample code
// not working!
window.onpopstate = function(event) {
console.log("location: " + document.location + ", state: " + event.state);
};
// not working!
const history = createBrowserHistory();
const location = history.location;
const unlisten = history.listen((location, action) => {
console.log('hello ! : ', action, location.pathname, location.state);
});
// but window.history.state is changed!