-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
XState version
XState version 5
Description
When trying to spawn or invoke a callback actor from a singleton app machine hooked up to React, the callback actor is invoked multiple times.
Expected result
As when using XState "directly" (without framework) where the callback actor is only run ONCE, it should do the same when initializing the main machine from React instead.
Actual result
The invoke runs the callback actor initiation TWICE. The same multiple invocation behavior is seen when using spawn via an action through either entry or always. Even a guard checking if the actor ref was defined did hot help.
The only way I managed to get it to be called ONCE is via an after (with both explicit and implicit guard).
Reproduction
https://stackblitz.com/edit/github-lbwzey48?file=src%2FApp.tsx
Additional context
Compare with: https://stackblitz.com/edit/github-zawrqp2b?file=src%2FfeedbackMachine.ts