4.15.1 spawn
return type causing issues, useActor() vs useService()?
#1761
Unanswered
joshuaaron
asked this question in
Q&A
Replies: 1 comment 3 replies
-
You should use export type AccordionPanelMachineInterpreter = ActorRefFrom<
Interpreter<AccordionPanelContext, any, AccordionPanelEvents>["machine"]
>; Take a look at the adjusted codesandbox: https://codesandbox.io/s/stoic-glitter-ojyy4 |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
The type returned from the
spawn()
method now returns a SpawnedActorRef, instead of Interpreter.I'm unsure if I should be using
useService()
vsuseActor()
to use these spawned actors in the 'child', as I would like to access the full machine for the child to get the full current state and utilize.matches
etc.Currently, if I use
useActor()
I only get the[currentEvent, send]
though if I try and useuseService()
, an error arises saying I've tried to use an actor in the service, please useuseActor()
instead.Am I left to use useActor here, and possibly architect the app differently? I was considering downgrading my version to receive the Interpreter return type back.
Apologies if this hasn't made as much sense, or if I'm going about this the wrong way, this is my first experience with xstate so I may be going about this incorrectly. Trying to convince my team to move over some complex UI to xstate and we're just dipping our feet.
Codesandbox here
Beta Was this translation helpful? Give feedback.
All reactions