npm xstate 4.3.0

latest releases: 4.33.1, 4.33.0, 5.0.0-alpha.0...
3 years ago
  • 🚚 Improved import/export experience!

The interpreter is now included in the main module:

- import { interpret } from 'xstate/lib/interpreter';
+ import { interpret } from 'xstate';

As well as common actions, send, assign, and sendParent:

- import { actions } from 'xstate';
- const { send, assign, sendParent } = actions;
+ import { send, assign, sendParent } from 'xstate';

This change is reflected in the documentation as well as the tests.

  • ⚛ī¸ Redux DevTools is now supported by XState. This can be turned off/on with the devTools property (true by default):
const service = interpret(someMachine, {
  devTools: false // don't show in Redux DevTools
});

ℹī¸ Note: JUMP and SKIP actions in the DevTools will have no effect on XState, because there is no reliable way to arbitrarily go from one state to another with state machines, especially if side-effects are executed.

  • 👓 Better TypeScript inference for event types is now available thanks to @sangallimarco #303
  • 🏷 Service IDs will now take the ID of the machine if one is not specified:
const machine = Machine({ id: 'foo', /* ... */ });

// ...
{
  invoke: {
    // Invoked child service will have .id === 'foo'
    src: machine
  }
}

Don't miss a new xstate release

NewReleases is sending notifications on new releases.