Skip to content
Version: xstate@5.0.0

fromTransition() function​

Returns actor logic from a transition function and its initial state.

A transition function is a function that takes the current state and an event and returns the next state.

Signature:

export declare function fromTransition<TContext, TEvent extends EventObject, TSystem extends ActorSystem<any>, TInput>(transition: (state: TContext, event: TEvent, actorContext: ActorContext<TransitionSnapshot<TContext>, TEvent, TSystem>) => TContext, initialContext: TContext | (({ input, self }: {
input: TInput;
self: TransitionActorRef<TContext, TEvent>;
}) => TContext)): TransitionActorLogic<TContext, TEvent, TInput>;

Parameters​

ParameterTypeDescription
transition(state: TContext, event: TEvent, actorContext: ActorContext<TransitionSnapshot<TContext>, TEvent, TSystem>) => TContextThe transition function that returns the next state given the current state and event.
initialContextTContext | (({ input, self }: { input: TInput; self: TransitionActorRef<TContext, TEvent>; }) => TContext)The initial state of the transition function.

Returns:

TransitionActorLogic<TContext, TEvent, TInput>

Actor logic