(HOC) With XState
Installation
npm install with-xstateoryarn add with-xstate
Require
Usage
In order to use withXState
first pass the machine state through a prop to your component and then wrap it
mapActionsToXState((dispatch) => {...})
takes a function that should return and object that contains a key, value pair, where each key is a machine state and its value should be another object that contain a key, value pair with the actions and the functions that should be execute once xstate added to the next state.
NOTE mapActionsToXState
pass dispatch
as optionally prop so you can dispatch redux actions in your state actions.
;;; const toggleMachine = ; const mapActionsToXState = 'machineState': { console } ; const WithXStateComponent = Component; <WithXStateComponent machineState=machine />