Skip to content
Version: xstate@5.0.0

State class​

Signature:

export declare class State<TContext extends MachineContext, TEvent extends EventObject, TActor extends ProvidedActor, TTag extends string, TResolvedTypesMeta = TypegenDisabled> 

Constructors​

ConstructorModifiersDescription
(constructor)(config, machine)Creates a new State instance that represents the current state of a running machine.

Properties​

PropertyModifiersTypeDescription
childrenComputeChildren<TActor>An object mapping actor names to spawned/invoked actors.
configurationArray<StateNode<TContext, TEvent>>The enabled state nodes representative of the state value.
contextTContext
errorunknownThe output data of the top-level finite state.
historyValueReadonly<HistoryValue<TContext, TEvent>>
machineAnyStateMachine
metareadonlyRecord<string, any>
nextEventsreadonlyArray<EventDescriptor<TEvent>>The next events that will cause a transition from the current state.
status'active' | 'done' | 'error' | 'stopped'Indicates whether the state is a final state.
tagsSet<string>
valueStateValue

Methods​

MethodModifiersDescription
can(event)Determines whether sending the event will cause a non-forbidden transition to be selected, even if the transitions have no actions nor change the state value.
from(stateValue, context, machine)staticCreates a new State instance for the given stateValue and context.
hasTag(tag)Whether the current state configuration has a state node with the specified tag.
matches(parentStateValue)Whether the current state value is a subset of the given parent state value.
toJSON()
toStrings(stateValue)Returns an array of all the string leaf state node paths.