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

V2 Internals Rewrite #100

Draft
wants to merge 12 commits into
base: develop
Choose a base branch
from
Draft

V2 Internals Rewrite #100

wants to merge 12 commits into from

Conversation

joshpensky
Copy link
Member

@joshpensky joshpensky commented Sep 16, 2021

Description

This introduces a rewrite of the react-router-guards internals, with some public-facing API changes

This builds on top of #84, #85, #98, and #99 to make the following changes:

  • routes changes are detected by a change in route.match (not location)
  • guard resolution is now a state machine! resolving <--> (error | redirect | render)
  • new guard function signature guard(context, next), where context contains the route to, from, meta, and an AbortSignal for cancelling fetches
  • returning next is now a requirement for guard functions
  • loading + error pages now correctly use overrides
  • all use of the internal __RouterContext has been removed—data returned from guards is now accessible via the useGuardData hook

What this does

Describe what changes were made in more detail

How to test

Describe how to test your changes

TODO

  • update documentation
  • tests tests tests!
  • remove use of internal RouterContext in favor of useGuardData?

@joshpensky joshpensky self-assigned this Sep 16, 2021
@joshpensky joshpensky added the work in progress Not ready yet for review label Sep 16, 2021
@joshpensky joshpensky changed the base branch from main to develop September 16, 2021 18:37
@vipulbhj
Copy link

Any updates on the new version ?

@susheelahegde
Copy link

@joshpensky Are you planning release this anytime soon?

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

Successfully merging this pull request may close these issues.

3 participants