Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. componentWillUnmount: function(e) {
  2. var result = confirm('遷移してもよろしいですか?');
  3. if (!result) {
  4. // prevent unmount
  5. }
  6. },
  7.  
  8. onUnload(event) {
  9. var result = confirm('遷移してもよろしいですか?');
  10. if (!result) {
  11. // prevent unmount
  12. }    
  13.  
  14. }
  15.  
  16. componentDidMount() {
  17. window.addEventListener("beforeunload", this.onUnload)
  18. }
  19.  
  20. componentWillUnmount() {
  21. window.removeEventListener("beforeunload", this.onUnload)
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement