statelyai / inspect

Inspect state transitions and actor communication
https://stately.ai/docs/inspector
MIT License
45 stars 5 forks source link

React.Strict breaks the inspector #44

Open diamond-darrell opened 2 weeks ago

diamond-darrell commented 2 weeks ago

Hello there, I've noticed an issue with the inspector when React.Strict mode is enabled. Basically, it gets stuck on actor execution after rerendering the component that provided the machine. The machine's runtime execution seems fine since we're reaching the idle state, but it makes the inspector unusable afterward. You can see it's working if the strict mode is disabled.

CodeSandbox

https://codesandbox.io/p/sandbox/stately-inspect-iframe-repro-forked-hwv7ch

davidkpiano commented 2 weeks ago

One small note: createBrowserInspector() is meant to be called outside of components; that may be a potential source of the problem. Can you try something like this instead?

const inspector = createBrowserInspector();

function Component() {
  // the rest of your code
}
diamond-darrell commented 2 weeks ago

@davidkpiano yes, I've updated the codesandbox example. The issue still happens