storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
84.51k stars 9.3k forks source link

[Bug]: Infinite loop rendering on `unboundStoryFn` #28811

Open Thebarda opened 2 months ago

Thebarda commented 2 months ago

Describe the bug

Hello, I've recently migrated storybook from v7 to v8 using the migration script. Since, there is an infinite loop on unboundStoryFn that causes re-rendering all my stories Screenshot 2024-08-05 at 14 19 36 You can find my config right here

Is there something related to my configuration?

Thanks

EDIT: When I open the canvas in a new tab, it does not render infinitely.

Reproduction link

https://github.com/centreon/centreon/blob/develop/centreon/packages/ui/.storybook/main.ts T

Reproduction steps

  1. Install dependencies using pnpm
  2. run pnpm storybook
  3. Go to a story then run the profiler

System

Storybook Environment Info:

  System:
    OS: macOS 14.5
    CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
    pnpm: 8.15.7 - ~/.nvm/versions/node/v20.11.1/bin/pnpm <----- active
  Browsers:
    Chrome: 127.0.6533.89
    Safari: 17.5
  npmPackages:
    @storybook/addon-a11y: ^8.2.7 => 8.2.7 
    @storybook/addon-docs: ^8.2.7 => 8.2.7 
    @storybook/addon-essentials: ^8.2.7 => 8.2.7 
    @storybook/addon-interactions: ^8.2.7 => 8.2.7 
    @storybook/addon-themes: ^8.2.7 => 8.2.7 
    @storybook/blocks: ^8.2.7 => 8.2.7 
    @storybook/manager-api: ^8.2.7 => 8.2.7 
    @storybook/mdx2-csf: ^1.1.0 => 1.1.0 
    @storybook/preview-api: ^8.2.7 => 8.2.7 
    @storybook/react: ^8.2.7 => 8.2.7 
    @storybook/react-vite: ^8.2.7 => 8.2.7 
    @storybook/test: ^8.2.7 => 8.2.7 
    @storybook/test-runner: ^0.19.1 => 0.19.1 
    @storybook/theming: ^8.2.7 => 8.2.7 
    msw-storybook-addon: ^2.0.3 => 2.0.3 
    storybook: ^8.2.7 => 8.2.7 
    storybook-addon-mock: ^5.0.0 => 5.0.0 
    storybook-dark-mode: ^4.0.2 => 4.0.2

Additional context

No response

greptile-apps[bot] commented 2 months ago

Disclaimer This information might be inaccurate, due to it being generated automatically The infinite loop on unboundStoryFn might be related to the StoryStore implementation. Specifically, check the fromId method in /code/core/src/preview-api/modules/store/StoryStore.ts. Ensure that the storyFn function does not cause re-renders by verifying the context and update logic. Review the getStoryContext method to ensure it does not introduce state changes that could trigger re-renders. Additionally, ensure that any hooks or state management within the story are not causing unintended side effects.

References

/.github/DISCUSSION_TEMPLATE/help.yml /code/lib/cli/src/automigrate/fixes/new-frameworks.ts /code/lib/cli/src/automigrate/fixes/prompt-remove-react.ts /code/core/src/preview-api/modules/store/StoryStore.ts /.github/comments/invalid-link.md /code/core/src/server-errors.ts /code/lib/cli/src/automigrate/index.test.ts /code/lib/cli/src/automigrate/fixes/mdx-gfm.ts /code/core/src/core-server/utils/mockdata/errors/NoMeta.stories.ts /code/lib/cli/src/automigrate/fixes/sb-scripts.test.ts /code/lib/cli/src/automigrate/fixes/missing-storybook-dependencies.ts /code/lib/instrumenter /.github/comments /code/lib/cli/src/automigrate/fixes/angular-builders-multiproject.ts /code/lib/cli/src/automigrate/fixes/addon-postcss.ts /code/lib/cli/src/automigrate/fixes/mdx-to-csf.ts /code/lib/cli/src/autoblock/block-storystorev6.ts /code/lib/cli/src/automigrate/fixes/vta.ts /CONTRIBUTING.md /code/core/src/preview-errors.ts /code/lib/cli/src/automigrate/helpers/getMigrationSummary.test.ts /.github/DISCUSSION_TEMPLATE/ideas.yml /docs/contribute/how-to-reproduce.mdx /code/addons/interactions/template/stories /code/lib/cli/src/automigrate/fixes/angular-builders.ts

#### About Greptile This response provides a starting point for your research, not a precise solution. Help us improve! Please leave a ๐Ÿ‘ if this is helpful and ๐Ÿ‘Ž if it is irrelevant. [Ask Greptile](https://app.greptile.com/chat/github/storybookjs/storybook/next) ยท [Edit Issue Bot Settings](https://app.greptile.com/apps/github)
Thebarda commented 2 months ago

After a bit of investigations, I found out the addon @storybook/addon-interactions causes the issue. I removed it because I don't use it and no extra renders ๐ŸŽ‰

spectrachrome commented 1 month ago

I have this issue too. Thank you @Thebarda for your input, possibly removing that dependency will help.