Hello! π
I'm working with XState as a beginner, and I'm encountering a very strange issue. I created a state machine and I'm trying to use emit via fromCallback after a state transition. Unfortunately, while I verified the callback is being invoked, I'm not getting any notifications from the Actor ref when I call emit. Example code is below.
// StateMachine.ts
const callback = fromCallback(({emit}) => {
someCallback.onEvent(data => {
// This is logged
console.log(data);
// This doesn't work π
emit({type: 'notify', data}
});
});
// *snip*
on: {
triggerEmit: {
target: '.someState'
}
},
states: {
someState: {
invoke: [
{ src: 'callback' }
],
}
}
// *snip*
// AComponent.tsx
const actor = SomeContext.useActorRef();
useEffect(() => {
actor.send({type: 'triggerEmit'});
actor.on('notify', data => {
// This doesn't work π
console.log(data);
});
}, [])