Skip to content

[Feature]: Add some hook functions #9085

Closed

Description

@ygs-code

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。

Activity

  1. added
    feature-request
    on Jul 21, 2022
  2. timdorr commented on Jul 21, 2022

    @timdorr
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions