I am working on react JS. I need either disable or customize the default message "Changes you made may not saved". I have used the code shown below, but there is no change in default message. Can Someone help to solve the issue.
Code used to customize the pop up message
useEffect(() => {
return () => {
window.addEventListener("beforeunload", function(e) {
let confirmationMessage = "'It looks like you have been editing something. ";
(e || window.event).returnValue = confirmationMessage; //Gecko + IE
formRegistered && handleSubmit(e)
console.log(" confirmationMessage", confirmationMessage)
return confirmationMessage; //Webkit, Safari, Chrome
});
}
});
code used to disable the pop up
useEffect(() => {
return () => {
window.addEventListener("beforeunload", function(e) {
let confirmationMessage = "/o ";
(e || window.event).returnValue = confirmationMessage; //Gecko + IE
formRegistered && handleSubmit(e)
console.log(" confirmationMessage", confirmationMessage)
return null; //Webkit, Safari, Chrome
});
}
});
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/wWyjJ.png