Packages

xstate

5.33.4 · 7 Nov 2026MIT9M / weekRepositoryHomepagenpmAtom feed

Your version

5.5.0

10 Jan 2024Where it was published

5.33.4 is the newest release of 5.x.

In short

2 new

Release note

Minor Changes

  • Introduce getNextSnapshot(...), which determines the next snapshot for the given actorLogic based on the given snapshot and event.

    If the snapshot is undefined, the initial snapshot of the actorLogic is used.

    import { getNextSnapshot } from 'xstate';
    import { trafficLightMachine } from './trafficLightMachine.ts';
    
    const nextSnapshot = getNextSnapshot(
      trafficLightMachine, // actor logic
      undefined, // snapshot (or initial state if undefined)
      { type: 'TIMER' }
    ); // event object
    
    console.log(nextSnapshot.value);
    // => 'yellow'
    
    const nextSnapshot2 = getNextSnapshot(
      trafficLightMachine, // actor logic
      nextSnapshot, // snapshot
      { type: 'TIMER' }
    ); // event object
    
    console.log(nextSnapshot2.value);
    // =>'red'

Patch Changes

  • Allow event in transitions to be narrowed down even when its .type is defined using a union.

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.