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

[Bug] Story template object prop containing JSX hangs the browser #493

Open
1 task
siggirh opened this issue Sep 2, 2022 · 0 comments
Open
1 task

[Bug] Story template object prop containing JSX hangs the browser #493

siggirh opened this issue Sep 2, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@siggirh
Copy link

siggirh commented Sep 2, 2022

What version of vite are you using?

3.0.9

System info and storybook versions

System:
OS: macOS 12.5.1
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Binaries:
Node: 18.7.0 - ~/.nvm/versions/node/v18.7.0/bin/node
npm: 8.15.0 - ~/.nvm/versions/node/v18.7.0/bin/npm
Browsers:
Chrome: 104.0.5112.101
npmPackages:
@storybook/addon-essentials: 6.5.9 => 6.5.9
@storybook/addon-links: 6.5.9 => 6.5.9
@storybook/builder-vite: 0.2.2 => 0.2.2
@storybook/react: 6.5.9 => 6.5.9

Describe the Bug

Object props to a component within a story template will crash the docs window (hang the browser) without the prop even being used. I can repro this just with the basic project setup.

  1. npm create vite
  2. choose react and react-ts
  3. y to "Do you want to run the npm7 migration on your project?"
  4. npx sb init --builder @storybook/builder-vite
  5. NODE_OPTIONS=--openssl-legacy-provider npm run storybook

Now everything is fine with the default components. So I edit the Header.stories.tsx file and add some random prop to the component with JSX in it as so:

- const Template: ComponentStory<typeof Header> = (args) => <Header {...args} />;
+ const Template: ComponentStory<typeof Header> = (args) => (
+  <Header {...args} prop={{ one: <div>one</div> }} />
+);
  1. Go back to storybook and to the Header component. Click the Docs tab and now everything is frozen. Browser tab hangs and chrome asks if I want to exit the page or wait. CPU is >100% until I kill the process.

EDIT: One more thing I figured out. If I move the JSX prop out of the template component it stops hanging/crashing. So something like this works:

- const Template: ComponentStory<typeof Header> = (args) => (
-  <Header {...args} prop={{ one: <div>one</div> }} />
-);
+ function Component(args: typeof Header) {
+   return <Header {...args} prop={{ one: <div>one</div> }} />;
+ }
+ const Template: ComponentStory<typeof Header> = (args) => (
+  <Component {...args} />
+);

Looked around a bit but couldn't find another issue that sounded like a similar issue.

I didn't add a repro project since I can repro this in any project just adding a nested JSX prop to the rendered template component.

Link to Minimal Reproducible Example

No response

Participation

  • I am willing to submit a pull request for this issue.
@siggirh siggirh added the bug Something isn't working label Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant