We should not useuseMachine to provide an invoked state machine in a context. useMachine spawns a machine in a component and kills it when the component unmounts.
Instead we need to follow the following pattern:
Provide the service in the context
Send events to the service by calling send function from the service
Use useSelector to extract some data from the current state
We should not use
useMachine
to provide an invoked state machine in a context.useMachine
spawns a machine in a component and kills it when the component unmounts.Instead we need to follow the following pattern:
send
function from the serviceuseSelector
to extract some data from the current state