React : Disable Browser Forward and Backward Button or Prevent Navigation

 React : Disable Browser Forward and Backward Button or Prevent Navigation 


To prevent navigation to specific route, we need to use history.block() - https://github.com/remix-run/history/blob/dev/docs/blocking-transitions.md


The browser backward button click action will be pop() and the browser forward button click action will be push(). We need to listen and handle these actions to block navigation.  


 

No comments:

Post a Comment