action to prevent transition from current route
See original GitHub issueaction
for use of history.block
api so that user can lock
or free
current route.
Possible use cases are unsaved forms, pending results etc.
Issue Analytics
- State:
- Created 6 years ago
- Comments:28 (15 by maintainers)
Top Results From Across the Web
Preventing and Retrying Transitions - Routing - Ember Guides
When a transition is attempted, whether via <LinkTo /> , transitionTo , or a URL change, a routeWillChange event is fired on the...
Read more >How to prevent route change using react-router - Stack Overflow
It is too late but according to the React Router Documentation you can use preventing transition with helping of <prompt> component.
Read more >Exclude some Routes from transition. · Issue #365 - GitHub
Rendering only routes if current route is /profile . This will prevent exiting animation of any previous route and entering animation of the ......
Read more >Route transition animations - Angular
When a user navigates from one route to another, the Angular router maps the URL path to a relevant component and displays its...
Read more >Animating Angular Route Transitions - DEV Community
During a transition, a new view is inserted directly after the old one and both elements appear on screen at the same time....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is done. It’s in the @next dist-tag on npm. to get it do:
Here’s how you use it:
So each route can have a
confirmLeave
option, and if you return a string it will be shown in theconfirm
yes|no dialog. If you return a falsy value such as undefined, the user will be able to navigate away from the current route without being shown any dialog.If you’d like to customize that dialog (which is required in React Native since there is no
window.confirm
in React Native), you can pass adisplayConfirmLeave
option toconnectRoutes
like so:One special thing to note is that if you define this function in the same scope that is likely created below, you can use
store.dispatch
to trigger showing the modal instead. You could even do:and then grab the callback in your
<Modal />
component. Since this is happening solely on the client and the store will never need to serialize thatcallback
(as you do when rehydrating from the server), this is a fine pattern. Redux store state can contain functions, components, etc, if you choose. The result in this case is something highly idiomatic when it comes to how you render the React component corresponding to the modal. No imperative tricks required.Here’s a final example:
src/reducers/blockNavigation.js:
src/components/BlockModal.js:
src/components/App.js
src/configureStore.js:
when rudy 0.0.1 is out we’ll need a few long-time users to migrate their codebases, so we can iron out kinks as fast as possible 😃
Other things we need:
ps. almost almost there