storybookjs/storybook

[Bug]: "useArgs" hook updates wrong story when rendered in "Stories" block

已关闭

#28,333 创建于 2024年6月24日

 (7 条评论) (9 个反应) (0 位负责人)TypeScript (10,058 个派生)batch import
addon: docsbughelp wantedsev:S3

仓库指标

星标
 (89,909 个星标)
PR 合并指标
 (平均合并 7天 22小时) (30 天内合并 184 个 PR)

描述

Describe the bug

When writing a story for a controlled component, one should expect the useArgs hook to update the args being passed to the story it is being called in. However, when used inside a "Stories" block, it updates the page's primary story instead of itself. This isn't an issue when using a "Canvas" block or any other block that selects a specific story. I'm sure this could be user error but I don't see why there would then be a discrepancy between the functionality between the "Stories" block and an individual "Story" block.

Reproduction link

https://stackblitz.com/edit/github-n2sxrc?file=src%2Fstories%2FInput.tsx

Reproduction steps

  1. Go to the "Input" docs in Storybook.
  2. Attempt to edit one of the stories under the "Stories" header.
  3. Notice that value of top story is changing, instead of the story being edited.

System

Storybook Environment Info:

  System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm <----- active
    pnpm: 8.15.6 - /usr/local/bin/pnpm

Additional context

No response

贡献者指南