In a hierarchical state graph onEntry action is fired on a solely nested transition although it is not defined in the nested graph.
onEntry only fires on entry to a state or on transition to itself but not on a transition of a nested sub graph.
onEntry action fires on every transition of nested state graphs.
This example generates a nested fooBar machine inside the ping state of a pingPong state machine.
const pingPong = Machine({
initial: 'ping',
states: {
ping: {
onEntry: ['entryEvent'],
on: {
TICK: 'pong'
},
initial: 'foo',
states: {
foo: {
on: {
TACK: 'bar'
}
},
bar: {
on: {
TACK: 'foo'
}
},
},
},
pong: {
on: {
TICK: 'ping'
}
},
}
});
Transition from nested state ping.foo to ping.bar on TACK fires entryEvent of the pingPong machine. Although we stay inside of the state and thus should not have the entryEvent fired.
pingPong.transition('ping.foo', 'TACK')
// => State {
// value: { ping: 'bar' },
// actions: [
// 'entryEvent' // WHY?!
// ]
// }
Can you provide an example of the state and the transition output?
I added the example to the main issue description and tested it in codepen.
https://codepen.io/nenti/pen/WdBpRd
Published in v3.0.3
Updated the version of the codepen and it looks great. Thank you for quick fix!
Most helpful comment
Published in v3.0.3