Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Add some hook functions #9085

Closed
ygs-code opened this issue Jul 21, 2022 · 1 comment
Closed

[Feature]: Add some hook functions #9085

ygs-code opened this issue Jul 21, 2022 · 1 comment
Labels

Comments

@ygs-code
Copy link

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。

@timdorr
Copy link
Member

timdorr commented 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants