Skip to content

Updating from 0.X.X to 1.0.0

Cassio Zen edited this page Jul 27, 2021 · 2 revisions

Version 1.0 introduces a few API changes:

  • No more curried function: Extended state is now declared within the State Machine configuration object
  • New signature for effects and guards

New Context Configuration:

Before

const [state, send] = useStateMachine(/* Context */)(/* Configuration */);

After

const [state, send] = useStateMachine(/* Configuration (including context) */);

effects and guards:

  • Both functions receive a single object with multiple keys instead of multiple parameters.
  • Effects now receive the context.
  • The context updater function inside effect is now called setContext instead of update.

Here's a diff between the fetch example on versions 0.x.x and 1.0.0:

Screen Shot 2021-06-14 at 10 19 43 AM
Clone this wiki locally