Skip to content

React <SignalValue> shim creates infinite recursion with Storybook #773

@bensaufley

Description

@bensaufley
  • Check if updating to the latest version resolves the issue

Environment

  • I am using @preact/signals-core
  • I am using @preact/signals
  • I am using @preact/signals-react

Describe the bug

I'm working on migrating a codebase that uses Signals from Preact to React and encountered an issue where components that use Signals throw a "Maximum call stack size exceeded" error. After some digging, I discovered the issue is that Storybook has an internal function called simplifyNodeForStringify, which is used for JSX stringification for docs (original PR: storybookjs/storybook#19188). This iterates over ReactNodes' props, recursively, and nullifies _owner in all ReactNodes. Because the SignalValue shim for signals-react defines the prop data as this, this creates infinite recursion.

To Reproduce

No actions needed to reproduce: go here and you can see it https://codesandbox.io/p/sandbox/jqpkdl

Expected behavior

I'm not sure what the data = this prop shim is intended to do, so I'm not sure how to resolve the issue. But obviously, the expectation is that @preact/signals-react does not break Storybook.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions