Custom notification dialogue/modal for setRouteLeaveHook?
See original GitHub issueHi,
I couldnt find any information online regarding this and the docs only show mention of window.confirm. Is it possible to set a custom notification for routeLeaveHook instead of using window.confirm
. I created a stackoverflow question regarding this and my particular use case for it in more detail and would like to know if this is currently possible or whether there is a specific reason why we cannot do this and whether this could be something implemented. I have a code example of how I would like to use it inside the question.
Im using react-router 2.0
What this feature means for your product. Currently the window.confirm dialog is quite clunky and doesnt fit into the UX and design for the site.
What will it allow you to do that you can’t do today? It will allow us to provide different means to transition from one route to the next in terms of both UI and UX.
How will it make current work-arounds straightforward? While @DanielSWolf provided a possible solution to me it feels that something like this should be built into the framework since in my opinion will become a fairly common requirement that setRouterLeaveHook should allow for since it feels like a variant on the same functionality (synchronous vs asynchronous).
What potential bugs and edge cases does it help to avoid? As mentioned above it not aboout avoiding bugs but rather expanding on the functionality of setRouterLeaveHook to accept an async flow. While this can be done via @DanielSWolf solution its seems like this is something that should be baked into the functionality that is already there since its just a variation of what one might require.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:14
- Comments:20 (7 by maintainers)
Please follow the issue template, @taion closed the issue as it didn’t follow the template.
@taion Thanks for clarifying. For anyone trying to do this but getting lost in the labyrinth of documentation, here’s how I did it:
Now if you return a string from your
setRouteLeaveHook
callback, it will be used for both soft transitions (those using the HTML5 API) and hard transitions (navigating to a different domain or refreshing the page).Overall I really like the API, but it would be awesome if this explanation was in https://github.com/reactjs/react-router/blob/master/docs/guides/ConfirmingNavigation.md