Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: @xstate/react system.get("actorSystemID") returns undefined on <StrictMode> #5074

Open
bsunderhus opened this issue Sep 13, 2024 · 0 comments
Labels

Comments

@bsunderhus
Copy link

bsunderhus commented Sep 13, 2024

XState version

XState version 5

Description

Here's a repro: https://stackblitz.com/edit/github-4nrvzx?file=src%2FfeedbackMachine.ts

On <StrictMode> the re-render is causing the reference returned by system.get to be undefined on the body of a fromCallback logic function:

image

image

Expected result

On <StrictMode> , system.get('feedback') should consistently return a reference to the feedbackActor instead of undefined

Actual result

If the machine spawning the reference is not the machine being accessed by system.get.

In this scenario I got 3 actors:

  1. root (machine)
  2. alert (fromCallback)
  3. feedback (machine)

If root spawns both actors then whenever alert function callback is called the second time (due to <StrictMode> re-rendering) then system.get('feedback') will return undefined ❌, while system.get('root') returns the actor reference ✅.

If root spawns feedback and feedback spawns alert then the problem is solved. ✅

Reproduction

https://stackblitz.com/edit/github-4nrvzx?file=src%2FfeedbackMachine.ts

Additional context

No response

@bsunderhus bsunderhus added the bug label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant