-
Hello people, How to send event from a child state that came from useMachine?
PedestianStates const pedestrianStates = {
initial: 'walk',
states: {
walk: {
on: {
PED_TIMER: 'wait'
}
},
wait: {
on: {
PED_TIMER: 'stop'
}
},
stop: {}
}
} Light Machine export const LightMachine = Machine({
key: 'light',
initial: 'green',
states: {
green: {
on: {
TIMER: 'yellow'
}
},
yellow: {
on: {
TIMER: 'red'
}
},
red: {
on: {
TIMER: 'green'
},
...pedestrianStates
}
}
}) I read on the documentation regarding on this, it could be access by I want to come up with something like triggering the state, send("red.walk", "wait"); |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Im having answers now, I guess invoker will be the solution Updates: For now I guess, I have to use Hierarchical State Nodes I guess both has their own advantages 👍 |
Beta Was this translation helpful? Give feedback.
-
You can't really send an event to a child state - you send it to a machine and the current configuration of states is being checked against available transitions for that sent event. |
Beta Was this translation helpful? Give feedback.
You can't really send an event to a child state - you send it to a machine and the current configuration of states is being checked against available transitions for that sent event.