Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot call component folder switch #19288

Open
cge-taal opened this issue Sep 29, 2022 · 3 comments
Open

Cannot call component folder switch #19288

cge-taal opened this issue Sep 29, 2022 · 3 comments

Comments

@cge-taal
Copy link

cge-taal commented Sep 29, 2022

Describe the bug

Storybook hangs when I call a component's containing folder switch.

To Reproduce

  • create a simple src/components/switch/index.tsx and src/components/switch/index.stories.tsx
  • run yarn storybook
  • see the storybook launch, but the spinner continues forever.

In the Brave browser dev console the error reads Uncaught SyntaxError: Unexpected token '.'

In Firefox it points to this part of the generated code in main.iframe.bundle.js:

try {
    // @ts-ignore
    switch.displayName = "switch";
    // @ts-ignore

Now rename the folder from switch to switchh to get src/components/switchh/index.tsx and src/components/switchh/index.stories.tsx and relaunch storybook to see it all working again.

System

$ npx sb@next info

Environment Info:

  System:
    OS: macOS 12.6
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 16.13.2 - /usr/local/bin/node
    Yarn: 1.19.0 - /opt/homebrew/bin/yarn
    npm: 8.1.2 - /usr/local/bin/npm
  Browsers:
    Chrome: 105.0.5195.125
    Edge: 105.0.1343.53
    Safari: 16.0

Additional context

  "@storybook/react": "^6.5.12",
  "react": "^18.2.0",
  "react-dom": "^18.2.0",
@cbovis
Copy link

cbovis commented Mar 24, 2023

Also discovered this issue today except in my case the file was called switch.tsx with an associated switch.stories.tsx file. Looks like special handling is required for this in Storybook.

@shilman
Copy link
Member

shilman commented Aug 23, 2023

Can you try out the following canary in your project and let me know whether it resolves any of your issues (or generates new ones)? We're looking to switch the default docgen from react-docgen-typescript to react-docgen, which is much faster and may also fix some long-standing bugs. Many thanks!

Note that the change is currently only for Vite projects. Instructions in the "how to test" section: 👉 #23825

@cge-taal
Copy link
Author

Good day, not logged in here very often so please excuse the delay. I've just tried "storybook": "^7.4.5" and renamed my switchh component folder (which works in 7.4.5) to switch and it stopped working.

I think this should be a super trivial case to test. Please try creating the simplest of components in a switch folder to test. Thanks for the efforts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants