What is the alternate of Prompt in react-router V6 ? usePrompt right ? If use usePrompt I am getting useBlock must be used within a data router.
I want to show a confirmation box if user click back button of browser or reload the browser screen.
As, react-router V6 don't update the history.pushState therefore popState is not executing...
#Want to show Prompt or confirmation box
1 messages · Page 1 of 1 (latest)
You must be using one of the router types that don't use browser's DOM History API (memory router? hash router?). The correct one to use is the browser router, since browser router uses DOM History API.
I am using BrowserRouter instead of createBrowserRouter hook. Do BrowserRouter not use browser's DOM History API ?
The component, as opposed to the function, is a migration path from v5 route definitions to v6's. AFAIK the component and the function is not exactly the same, and they are not interchangeable.
You should consider fully migrating to the function.
Further reading: https://reactrouter.com/en/main/upgrading/v6-data
Is there any option other than changing ? I am agree it is good to switch to createBrowserRouter.
BTW thank you for your help