useMachineState
useMachineState<
Value>(machine,entity):TopStateName<Value> |undefined
The top state the machine on entity is in, read from its record, or
undefined while entity is undefined or holds no record. Pass the
world for the world’s machine. It rerenders when the top state changes,
on a replica as the stream writes it, and stays as it is while a wait
counts its seconds.
A state that holds states reads as its own name: "fight" while the
siege is in fight.opening. A parallel machine keeps its regions one
state down, since states() takes one initial state at the top, so it
reads as the parallel state’s name while its regions move. Read a state
inside another with its tag: useHas(entity, Siege.is.fight.opening).
const siege = useQueryFirst(Siege.trait);const phase = useMachineState(Siege, siege); // "waiting" | "fight" | ...Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
Value |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
machine |
{ trait: Trait; read: { value: Value; }; } |
machine.trait |
Trait |
machine.read |
|
entity |
Target |
Returns
Section titled “Returns”TopStateName<Value> | undefined