You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the new or updated feature that you are suggesting?
I would like to add the beforeEnter afterEach hook function to the Route component,
BeforeEnter afterEach hook function takes three arguments,
to: route: indicates the destination route to be entered,
from: route: indicates the route that the current navigation is about to leave,
next: function: Be sure to call this method to resolve the hook. The execution depends on the next method。
So I can do some authorization interception in the hook function, or request interception。
Why should this feature be included?
So I can do some authorization interception in the hook function, or request interception。Also in SSR I have some data that I want the server to complete the request before handing it to the client。So you need these hook functions。
If you can please add such a function, thank you。
These kinds of things have been suggested in the past, but aren't really possible with the way React works with asynchronous code nowadays. We have no way to stop the rendering of a component, just defer it.
Activity
timdorr commentedon Jul 21, 2022
These kinds of things have been suggested in the past, but aren't really possible with the way React works with asynchronous code nowadays. We have no way to stop the rendering of a component, just defer it.
But much of what you're asking for is coming in 6.4.0. You can read about it here: https://beta.reactrouter.com/en/dev/getting-started/data
Scope single fetch headers calls to only loaded routes (#9085)