Consolidate Router State Access #12358
ryanflorence
announced in
Official RFCs
Replies: 2 comments 1 reply
-
Love seeing the API surface shrinking. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Not fully agree on this. Love seeing the API simplified in usage however accessing these API's directly could also benefit a lot of use cases. Putting it all into a single solution would probably make it way too opiniated. But love to see the addition to simplify the usage in general |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Right now you access active, pending, and transitioning states from a bunch of different hooks. This proposal hopes to consolidate them all into a simpler API.
Today
Accessing Current States
Accessing Pending States
Accessing View Transition States
Proposal: Consolidate into one hook
All of those hooks are either accessing active/pending states or matching against a path and providing active/pending states. We can do this with one hook.
By providing a path to the hook, we can match against it to determine the states, and even provide better types
Deprecations
This one hook can deprecate all eight of these:
useLocation
useSearchParams
useParams
useTransitionState
useNavigation
useMatches
useMatch(pattern)
useNavigationType
Refactor
Probably some potential refactoring to simplify the code and have the deprecated hooks (and NavLink) use the new hook underneath.
Beta Was this translation helpful? Give feedback.
All reactions