Prompt for unsaved change for JavaScript or React application

1
2
import { withRouter } from 'react-router';
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
In React application, it is needed to check against page transition via React Router API since it is not a pure redirect which will not trigger onbeforeunload event.

In pure JavaScript application, you just need to assign callback function to window.onbeforeunload.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.