remix-run / history

Manage session history with JavaScript
MIT License
8.29k stars 961 forks source link

Allow adding blockers that don't create a beforeUnload event #949

Open karlshea opened 2 years ago

karlshea commented 2 years ago

This allows adding blockers that don't create a beforeUnload event, so blocks can prevent or otherwise handle location changes but won't block reloading the page.

Normal blockers are looked at first (to support prompts), and then if they all allow the transaction the no-unload blockers are checked afterwards.

See #921 for reasoning (forcing a full page load for non-SPA routes). What are the maintainer's thoughts on this approach?

ofirgeller commented 1 year ago

Could also add a flag to block. would like to see some solution merged, I had to drop the blocking feature on an app so i can upgrade to react-router v6 which sucks :(