Skip to content
Version: xstate@5.0.0

StateNode class​

Signature:

export declare class StateNode<TContext extends MachineContext = MachineContext, TEvent extends EventObject = EventObject> 

Constructors​

ConstructorModifiersDescription
(constructor)(config, options)Constructs a new instance of the StateNode class

Properties​

PropertyModifiersTypeDescription
afterreadonlyArray<DelayedTransitionDefinition<TContext, TEvent>>
always?Array<TransitionDefinition<TContext, TEvent>>(Optional)
configStateNodeConfig<TContext, TEvent, TODO, // actions TODO, // actors TODO, // output TODO, // guards TODO, // delays TODO>The raw config used to create the machine.
definitionreadonlyStateNodeDefinition<TContext, TEvent>The well-structured state node definition.
description?string(Optional)
entryUnknownAction[]The action(s) to be executed upon entering the state node.
eventsreadonlyArray<TEvent['type']>All the event types accepted by this state node and its descendants.
exitUnknownAction[]The action(s) to be executed upon exiting the state node.
historyfalse | 'shallow' | 'deep'

The type of history on this state node. Can be:

- 'shallow' - recalls only top-level historical state value - 'deep' - recalls historical state value at all levels

idstringThe unique ID of the state node.
initialreadonlyInitialTransitionDefinition<TContext, TEvent>
invokereadonlyArray<InvokeDefinition<TContext, TEvent, ProvidedActor, ParameterizedObject, ParameterizedObject, string>>The logic invoked as actors by this state node.
keystringThe relative key of the state node, which represents its location in the overall state value.
machineStateMachine<TContext, TEvent, any, // actors any, // input TODO, // output TODO, // guards TODO, // delays TODO, // tags TODO>The root machine node.
meta?any(Optional) The meta data associated with this state node, which will be returned in State instances.
onreadonlyTransitionDefinitionMap<TContext, TEvent>The mapping of events to transitions.
ordernumberThe order this state node appears. Corresponds to the implicit document order.
output?Mapper<MachineContext, EventObject, unknown, EventObject> | NonReducibleUnknown(Optional) The output data sent with the "xstate.done.state._id_" event if this is a final state node.
ownEventsreadonlyArray<TEvent['type']>

All the events that have transitions directly from this state node.

Excludes any inert events.

parent?StateNode<TContext, TEvent>(Optional) The parent state node.
pathstring[]The string path from the root machine node to this node.
statesStateNodesConfig<TContext, TEvent>The child state nodes.
tagsstring[]
transitionsMap<string, TransitionDefinition<TContext, TEvent>[]>
type'atomic' | 'compound' | 'parallel' | 'final' | 'history'

The type of this state node:

- 'atomic' - no child state nodes - 'compound' - nested child state nodes (XOR) - 'parallel' - orthogonal nested child state nodes (AND) - 'history' - history state node - 'final' - final state node

Methods​

MethodModifiersDescription
_initialize()
next(state, event)
toJSON()