Description
xstate/[email protected] causes an issue with sending events from a parent machine to a child machine.
Expected Result
Sending an event from the parent machine to the child machine causes the child to transition and fire any actions associated with the transition.
Actual Result
The child seems to transition to the new state but doesn't run the actions
Reproduction
Steps to reproduce:
Additional context
Happens in xstate/[email protected]
Works in xstate/[email protected]
Verified this - it's because invoked machines inherit options from the parent, and in rc.4, execute is set to false (because React executes side-effects in useEffect) and that is set in child interpreters as well.
The fix here is to _not_ inherit the execute option. Will fix soon.
What's the current workaround for this? Currently using:
@xstate/react: 1.0.0-rc.6
xstate: 4.12.0
@cybervaldez This seems to be working in the latest XState 4.12 and @xstate/react 1.0.0-rc.6: https://codesandbox.io/s/xstate-react-reddit-example-with-actors-forked-7k3zk?file=/src/machine.js
Closing this.
Most helpful comment
Verified this - it's because invoked machines inherit options from the parent, and in
rc.4,executeis set tofalse(because React executes side-effects inuseEffect) and that is set in child interpreters as well.The fix here is to _not_ inherit the
executeoption. Will fix soon.