Given the above machine, send the following sequence of events in the simulator:
child1.next
child2.next
child1.history
child1.history
child1.history
...
Expected result
Whenever history is called, both machines stay in their previous state as (I think?) is expected. I use this pattern in my application to intercept events that need to do actions without changing any states.
Actual result
Although we get this result in the simulator, in real XState code it behaves differently. If both machines are in their Next states and child1.history is sent, one of the machines changes back to its initial state.
This can be reproduced by clicking on the buttons in the codesandbox. In this case when both machines are in Next and child1.history is sent, Child1 goes back to its initial state.
Note that in my actual app in fact it is Child2 (i.e. the machine without the history state) which goes back to its initial state and Child1 stays where it is.
XState version
XState version 5
Description
Given the above machine, send the following sequence of events in the simulator:
child1.next
child2.next
child1.history
child1.history
child1.history
...Expected result
Whenever history is called, both machines stay in their previous state as (I think?) is expected. I use this pattern in my application to intercept events that need to do actions without changing any states.
Actual result
Although we get this result in the simulator, in real XState code it behaves differently. If both machines are in their
Next
states andchild1.history
is sent, one of the machines changes back to its initial state.This can be reproduced by clicking on the buttons in the codesandbox. In this case when both machines are in
Next
andchild1.history
is sent,Child1
goes back to its initial state.Reproduction
https://codesandbox.io/p/sandbox/jolly-meadow-5sxz66
Additional context
Note that in my actual app in fact it is
Child2
(i.e. the machine without the history state) which goes back to its initial state andChild1
stays where it is.