feat(router): implement otherwise/routeNotFound hook
See original GitHub issueWe need some way to deal with the following cases:
- Route doesn’t match
- CanActivate returns
false
- CanDeactivate returns
false
This might not all be implemented the same way.
Issue Analytics
- State:
- Created 8 years ago
- Comments:17 (8 by maintainers)
Top Results From Across the Web
Using Hooks with React Router - LogRocket Blog
In this tutorial, you can learn how to use Hooks with React Router and minimize code lines in a component.
Read more >Invoke hook from React Router data router action
As configuration and action are now outside of a functional component, I cannot make use of the useAuthentication hook. My configuration looks ...
Read more >React Hook Router - GitHub
The flexible, and fast router for react that is entirely based on ... Detailed documentation about how to use hookrouter can be found...
Read more >useLoaderData v6.6.0 - React Router
This hook provides the value returned from your route loader. import { createBrowserRouter, RouterProvider, useLoaderData, } from "react-router-dom"; ...
Read more >Verizon Router User Guide
QoS support (end to end layer 2/3) featuring: Differentiated ... C. Connect the power cord to your router then to an electrical outlet....
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 Free
Top 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
New to the Party, and Angular2, But I am also looking for an implementation as described by @janneromell
I do not think the “is authenticated” check should be done in the CanActivate handler. It is not the concern of the CanActivate handler of a specific component. And you would have to put it on every component that is a routing target. And how would you distinguish between a “no data present” and a “not authenticated” event?
In the ui-router you have a stateChangeStart event. A similar concept seems to be missing in the angular 2 router, maybe for good reasons? After all, it is already possible to listen to “navigation finish” events.
But I would be wary of giving access to the Router service in a handler (CanActivate or startNavigation handler) in order to change the routing, this could get tricky. At first glance, it seems cleaner if such a navigationStart handler should be able to return something that the router resolves to a new (navigation) Instruction that overrides the original one in exceptional case like an authentication check.