I'm working on plugin for wordpress that used React and React Router Dom. One part of this plugin is settings page. Wordpress by default have functionality so when you made some edits on page and trying leave page worpdress open dialog box with "Leave site?" phrase.
I know that this functionality should be added with addEventListener to beforeunload event. This already added in wordpress by default. And when I add
window.onbeforeunload = () => true;
it's work fine when I trying move to another page.
But maybe someone know - is it possible trigger(fire but not add it's already added) this event programatically via js. Issue that when I change route in react and react-router-dom scoupe this event do not fire because browser think that page stay the same.