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

New JSX Transform in React 17 not working for component stories #12920

Closed
alonfai opened this issue Oct 26, 2020 · 3 comments
Closed

New JSX Transform in React 17 not working for component stories #12920

alonfai opened this issue Oct 26, 2020 · 3 comments

Comments

@alonfai
Copy link

alonfai commented Oct 26, 2020

Bug or support request summary

Hey all,

I recently upgraded to latest React 17 with support of new JSX transform. I ran the given code mod (https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#removing-unused-react-imports) to remove the default import React from 'react' in each of my typescript .tsx files.

I now run into problems with all my stories .tsx , that complains with an error ReferenceError: React is not defined (see attached preview).

I tried to implement the solution I found here (jakelazaroff/react-storybook-decorator-background#2 (comment)) by inserting the import statement into the preview.js file, but with no success.

If I return the default import into any of the existing stories, then the story component renders successfully.

Screen Shot 2020-10-27 at 10 37 46 am

Please specify which version of Storybook and optionally any affected addons that you're running

"@storybook/addon-a11y": "^6.0.27",
"@storybook/addon-essentials": "^6.0.27",
"@storybook/addon-jest": "^6.0.27",
"@storybook/addon-knobs": "^6.0.27",
"@storybook/addon-links": "^6.0.27",
"@storybook/addon-storysource": "^6.0.27",
"@storybook/addons": "^6.0.27",
"@storybook/preset-scss": "^1.0.3",
"@storybook/react": "^6.0.27",
@shilman
Copy link
Member

shilman commented Oct 27, 2020

Closing as dupe to #12881

@vctqs1
Copy link
Contributor

vctqs1 commented Nov 1, 2021

Could you share your solution, I meet the same issue, tried (jakelazaroff/react-storybook-decorator-background#2 (comment)) but not work

@vctqs1
Copy link
Contributor

vctqs1 commented Nov 1, 2021

I'll temporary copy babel file to bypass

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