[@xstate/react] Add Context Consumer #5267
Unanswered
RemyMachado
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd like
createActorContext
to expose a.Consumer
similar toReact.createContext
.It would be used like this:
React.js documentation on the subject: https://react.dev/reference/react/createContext#consumer
I like to consume the context like this because I don't have to create an intermediary component just to be able to use the hook.
For instance, without the
Consumer
, I need to do:This forces me to split the component unnecessarily just to satisfy the hook rules. For simple components or low-level consumers, using a
.Consumer
would reduce boilerplate.Beta Was this translation helpful? Give feedback.
All reactions