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.

Upgrading to React 17 on app level breaks UI

See original GitHub issue

Here’s the repro: https://github.com/Hypnosphi/test-storybook-react-17

Error I get is:

react.development.js:1431 Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.
    at resolveDispatcher (react.development.js:1431)
    at Object.useContext (react.development.js:1439)
    at useTheme (emotion-theming.browser.esm.js:112)
    at useMenu (vendors~main.619dfba2fee0a3e45bd3.bundle.js:25841)
    at Object.mapper [as current] (vendors~main.619dfba2fee0a3e45bd3.bundle.js:26274)
    at ManagerConsumer (vendors~main.619dfba2fee0a3e45bd3.bundle.js:1484)
    at renderWithHooks (vendors~main.619dfba2fee0a3e45bd3.bundle.js:42664)
    at mountIndeterminateComponent (vendors~main.619dfba2fee0a3e45bd3.bundle.js:45343)
    at beginWork (vendors~main.619dfba2fee0a3e45bd3.bundle.js:46457)
    at HTMLUnknownElement.callCallback (vendors~main.619dfba2fee0a3e45bd3.bundle.js:28049)

Brief debugging showed that useTheme imports React from DLL while the rest of manager UI imports it from node_modules/@storybook/ui/node_modules/react

Screenshot 2020-09-08 at 04 15 20 Screenshot 2020-09-08 at 04 16 04

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:14
  • Comments:41 (24 by maintainers)

github_iconTop GitHub Comments

15reactions
shilmancommented, Nov 4, 2020

Fixed in #12972 / 6.1-beta. Closing.

npx sb@next upgrade --prerelease
10reactions
bcomnescommented, Oct 31, 2020

Thanks @dburles we’re trying to get it back into latest now 😅

Any plans to also increase the react-dom range to support 17?

Edit, looks like there are issues with npm 7 + storybook as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React v17.0 – React Blog
React 17 enables gradual React upgrades. When you upgrade from React 15 to 16 (or, this time, from React 16 to 17), you...
Read more >
Upgrading to React 17 - Medium
We finally upgraded our app to React v17 from v16. The v17 was released almost 3 years after the previous major release.
Read more >
Upgrading to React 17 and Webpack 5 | by Chameera Dulanga
This article will discuss the steps to upgrading a React project to React 17 and Webpack 5 with my own set of tips...
Read more >
An Ultimate Guide to Upgrading to React 18 - OpenReplay Blog
It makes it easier to build interactive UIs by enabling you to create reusable UI components that can be used to build the...
Read more >
React 16 vs. React 17 | NextLink Labs
High Level Changes · Partial upgrade support · Supports the latest version of JSX · Supports nesting multiple react apps on the same...
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