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

Not working with React 17 #14065

Closed
nemonemi opened this issue Feb 26, 2021 · 9 comments
Closed

Not working with React 17 #14065

nemonemi opened this issue Feb 26, 2021 · 9 comments

Comments

@nemonemi
Copy link

nemonemi commented Feb 26, 2021

Describe the bug
I have updated my project to React 17.0.1 and Storybook 6.1.20.

Now, when I run the storybook, terminal displays this error:
image

If I would add the @babel/plugin-transform-react-jsx plugin to the main.js, the storybook would be built successfully, but the message in the place of components would be to React is not found.

I have tried reintroducing the React dependency to the places where I've removed it, but then it says Cannot read property 'a' of undefined and it points to a line in some method where the return { is (doesn't make much sense).

To me, it seems that out of the box the Storybook doesn't support React 17's Reactless components.

What else is there to be configured?

Expected behavior
It should render components like before the React upgrade.

Screenshots
If applicable, add screenshots to help explain your problem.

Code snippets
main.js

module.exports = {
  stories: [
    '../src/**/*.story.mdx',
    '../src/**/*.story.@(js|jsx|ts|tsx)',
    '../src/**/*.stories.mdx',
    '../src/**/*.stories.@(js|jsx|ts|tsx)',
  ],
  addons: [
    '@storybook/addon-links',
    '@storybook/addon-essentials',
    '@storybook/addon-storysource',
    '@storybook/addon-knobs',
    '@storybook/addon-actions',
  ],
  babel: async (options) => ({
    ...options,
    plugins: [...options.plugins, '@babel/plugin-transform-react-jsx'],
  }),
};

System
Environment Info:

System:
OS: Windows 10 10.0.17763
CPU: (8) x64 Intel(R) Core(TM) i7-10610U CPU @ 1.80GHz
Binaries:
Node: 14.15.5 - ~\AppData\Local\Volta\tools\image\node\14.15.5\node.EXE
Yarn: 1.22.10 - ~\AppData\Local\Volta\tools\image\yarn\1.22.10\bin\yarn.CMD
npm: 6.14.11 - ~\AppData\Local\Volta\tools\image\node\14.15.5\npm.CMD
Browsers:
Chrome: 88.0.4324.190
npmPackages:
@storybook/addon-actions: 6.1.20 => 6.1.20
@storybook/addon-essentials: 6.1.20 => 6.1.20
@storybook/addon-knobs: 6.1.20 => 6.1.20
@storybook/addon-links: 6.1.20 => 6.1.20
@storybook/addon-storysource: 6.1.20 => 6.1.20
@storybook/react: 6.1.20 => 6.1.20

@shilman
Copy link
Member

shilman commented Feb 26, 2021

do you have a custom babel config in your project root? if so, try removing it temporarily. if that works, you can override it with a custom babel config in the .storybook directory as a workaround.

@nemonemi
Copy link
Author

nemonemi commented Feb 27, 2021

I do have one in my root.
I have tried creating an empty {} one in the .storybook folder but that didn't help. I'll try removing the one from the root as well asap.

However, is there any specific configuration for React 17 that I've should have configured, perhaps?

@shilman
Copy link
Member

shilman commented Feb 27, 2021

No, if you're using 6.1, react17 should "just work"

@olabaloo
Copy link

olabaloo commented Mar 2, 2021

FWIW: I do not see this error - however, using npm 6 I can upgrade to React 17 with no problems.

Using npm 7, npm disallows me to upgrade to React 17 due to the Storybook peer dependency react-helmet-async not supporting React 17 (mentioned in staylor/react-helmet-async#109).
image

@shilman
Copy link
Member

shilman commented Mar 2, 2021

@olabaloo I think you need --legacy-peer-deps per the error message

@charkour
Copy link

charkour commented May 5, 2021

I feel like using --legacy-peer-deps is not the best long-term solution. This could cause issues down the road if there are breaking changes between versions that are peer deps.

@shilman
Copy link
Member

shilman commented May 5, 2021

@charkour yep it's a workaround. however to properly fix the problem requires a lot of changes in libraries that we don't control, so it will have to do in the meantime

@charkour
Copy link

charkour commented May 5, 2021

Sounds good. I totally understand! Thanks

@nemonemi
Copy link
Author

From my perspective, we can close this.

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

4 participants