Add useInDataRouterContext hook #11347
fzaninotto
started this conversation in
Proposals
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Problem
New hooks like
useBlocker
can only be called from within aDataRouterContext
. In the context of react-admin, we want to support apps with both a legacy router context and a data router context. Therefore we need to detect if we are in a data router context or not.Since the
DataRouterContext
isn't exported by react-router, we need to rely onUNSTABLE_
exports:Solution
Just like react-router exposes a
useInRouterContext
hook, expose a (stable)useInDataRouterContext
hook so that we can write:Beta Was this translation helpful? Give feedback.
All reactions