react-router-guards icon indicating copy to clipboard operation
react-router-guards copied to clipboard

V2 Internals Rewrite

Open joshpensky opened this issue 3 years ago • 2 comments

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!
  • [x] remove use of internal RouterContext in favor of useGuardData?

joshpensky avatar Sep 16 '21 15:09 joshpensky

Any updates on the new version ?

vipulbhj avatar Aug 29 '22 11:08 vipulbhj

@joshpensky Are you planning release this anytime soon?

susheelahegde avatar Jan 27 '23 10:01 susheelahegde