Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useNavigationPrompt does not work with Back button

See original GitHub issue

Thanks for the work & maintenance you put into this router. I have found an issue where I have a complex form, and need to prompt the user if they try to navigate away with unsaved changes. That works great for events that trigger the beforeunload event (hard page reload, navigate to a different site outside the SPA) or that use raviger’s navigate, but it doesn’t work with the browsers Back button.

Has there been any consideration for supporting the interception of the back button within the SPA?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:23 (23 by maintainers)

github_iconTop GitHub Comments

roypearcecommented, Jun 18, 2021

Awesome, thank you so much!

kyeoticcommented, Jun 18, 2021

published under 2.3.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to go back to previous route in react-router-dom v6
Try this approach import { useNavigate } from 'react-router-dom'; function YourApp() { const navigate = useNavigate(); return ( <> <button ...
Read more >
Preventing going back
Disable back swipe gesture; Override system back button/gesture on Android. However, this approach has many important differences in addition to being less code ......
Read more >
Prompt not preventing navigation when clicking browser ...
Prompt not preventing navigation when clicking browser back button or history.goBack() and previous page is external URL #5875.
Read more >
Xamarin Forms: Exit prompt is not working when use ...
PushAsync for loading a new page. I am showing a prompt for the exit when a user taps the device back button on...
Read more >
Upgrading from v5 v6.6.1
The history library is a direct dependency of v6 (not a peer dep), so you won't ever import or use it directly. Instead,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found