question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ArgsTable breaks if the component's displayName doesn't match its export name

See original GitHub issue

Describe the bug If a story for a React component renders an ArgsTable block, and the component’s displayName doesn’t match its export name, then the ArgsTable will render this error instead of the component’s props:

No inputs found for this component.

To Reproduce https://github.com/TrevorBurnham/sb-displayname-breaks-argstable

System

Environment Info:

System: OS: macOS 11.4 CPU: (16) x64 Intel® Core™ i7-10700K CPU @ 3.80GHz Binaries: Node: 15.10.0 - ~/.volta/tools/image/node/15.10.0/bin/node Yarn: 2.4.2 - ~/.volta/tools/image/yarn/1.22.10/bin/yarn npm: 7.5.3 - ~/.volta/tools/image/node/15.10.0/bin/npm Browsers: Chrome: 91.0.4472.114 Firefox: 88.0.1 Safari: 14.1.1 npmPackages: @storybook/addon-actions: ^6.4.0-alpha.3 => 6.4.0-alpha.3 @storybook/addon-docs: ^6.4.0-alpha.3 => 6.4.0-alpha.3 @storybook/addon-essentials: ^6.4.0-alpha.3 => 6.4.0-alpha.3 @storybook/addon-links: ^6.4.0-alpha.3 => 6.4.0-alpha.3 @storybook/react: ^6.4.0-alpha.3 => 6.4.0-alpha.3

Additional context This issue doesn’t occur when the ArgsTable is created implicitly as part of the default DocsPage behavior. I’ve only been able to replicate it when rendering an ArgsTable directly using the docs.page parameter.

I was able to work around the issue in my project by forcing react-docgen-typescript to use the expression name as the component name:

// in .storybook/main.js
module.exports = {
  // ...
  typescript: {
    reactDocgenTypescriptOptions: {
      componentNameResolver: (expression) => {
        return expression.getName();
      },
    }
  }
}

However, this has the unwanted side effect of causing the expression name to be used instead of the displayName in example code as well.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
TrevorBurnhamcommented, Dec 5, 2021

Update 12/5/2021: The problem lies in react-docgen-typescript-plugin, which relies on the component displayName returned by react-docgen-typescript as a proxy for its identifier (https://github.com/hipstersmoothie/react-docgen-typescript-plugin/issues/51). I’ve contributed a patch to react-docgen-typescript that allows the actual identifier to be accessed (https://github.com/styleguidist/react-docgen-typescript/pull/398), and that patch is in the react-docgen-typescript@2.2.1 release.

Unfortunately, react-docgen-typescript@2.2.1 requires typescript >= 4.3. So if react-docgen-typescript-plugin were updated to use it (draft PR: https://github.com/hipstersmoothie/react-docgen-typescript-plugin/pull/58), Storybook would also need to have that requirement.

0reactions
sarahquigleycommented, Sep 13, 2022

Is there any plan to fix this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ArgsTable - Storybook - JS.ORG
Storybook is a frontend workshop for building UI components and pages in isolation. Thousands of teams use it for UI development, testing, and...
Read more >
Need help getting UPN's from a list of Names : r/PowerShell
I have a CSV with a list of names under a header "username" ... I'm given a list of names that doesn't necessarily...
Read more >
Extension:Scribunto/Lua reference manual/vi - MediaWiki
This manual documents Lua as it is used in MediaWiki with the Scribunto ... scribunto-doc-page-name —Sets the name of the page used for...
Read more >
MIGRATION.md - Storybook - Fossies
If you don't specify a component file, it will be inferred from the file's location on ... Button'; export default { component: Button...
Read more >
@storybook/react | Yarn - Package Manager
Storybook for React: Develop React Component in isolation with Hot Reloading. storybook. readme. Storybook. Build bulletproof UI components faster. Build Status ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found