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
effectsandguards
New Context Configuration:#
Before
tsconst [state, send] = useStateMachine(/* Context */)(/* Configuration */);
tsconst [state, send] = useStateMachine(/* Context */)(/* Configuration */);
After
tsconst [state, send] = useStateMachine(/* Configuration (including context) */);
tsconst [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
effectis now calledsetContextinstead ofupdate.
Here's a diff between the fetch example on versions 0.x.x and 1.0.0:
