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.

Not working with React 17

See original GitHub issue

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® Core™ 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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
olabaloocommented, 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 https://github.com/staylor/react-helmet-async/issues/109). image

2reactions
shilmancommented, Mar 2, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does not work with React 17 - Readme implies works for 16+ ...
I have a react17 project. Installation results in peerDependency error. The latest version (v13.3.0)'s package.json contains "react": ...
Read more >
React v17.0 – React Blog
We're fixing many of those problems with React 17. This means that when React 18 and the next future versions come out, you...
Read more >
React 17 and webpack 5 not working in IE11 - Stack Overflow
I have looked into everything I could about the migration to react 17 and webpack 5. This for an application that is also...
Read more >
Upgrading to React 17: How to Fix the Issues and Breaking ...
Storybook 6.1 is compatible with React 17, but we were still using 6.0 which is not. Upgrading to 6.1 involved updating our webpack...
Read more >
Troubleshooting | React Navigation
Sometimes it might even be due to a corrupt installation. If clearing cache didn't work, try deleting your node_modules folder and run npm...
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