Option to show a pop confirmation before route change #27242
AkashGoenka
started this conversation in
Ideas
Replies: 2 comments 1 reply
-
You could build something similar using |
Beta Was this translation helpful? Give feedback.
0 replies
-
#2476 (comment) makes use of https://nextjs.org/docs/api-reference/next/router#routerevents. But that seems more like a workaround (not the cleanest way). I want to implement some checks before the next framework starts to unmount the component. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the feature you'd like to request
I had come across a use case where we had to warn user before they leave the page to another URL or in App Navigation. It would be great to have a feature to perform some logic before route change is initiated.
Describe the solution you'd like
A router event like
beforeRouteChange
that triggers a callback function where additional business logic can be executed and the routing can be halted/continued on the basis of a boolean returned by the callback.Another option would be something similar to https://reactrouter.com/core/api/Prompt
Describe alternatives you've considered
I've tried to use window.onbeforeunloadevent, but this does not work in all scenarios (especially in app navigation). It is triggered mostly on closing the tab/browser window.
Another option was a workaround suggested in - #2476 (comment)
Beta Was this translation helpful? Give feedback.
All reactions