Upgrading from 0.x.x
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
andguards
#
New Context Configuration:Before
ts
const [state, send] = useStateMachine(/* Context */)(/* Configuration */);
ts
const [state, send] = useStateMachine(/* Context */)(/* Configuration */);
After
ts
const [state, send] = useStateMachine(/* Configuration (including context) */);
ts
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 calledsetContext
instead ofupdate
.
Here's a diff between the fetch example on versions 0.x.x and 1.0.0: