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.

Error: "export 'useId' (imported as 'React') was not found in 'react'" after upgrading to v5.2.0

See original GitHub issue

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Building a project on React 17 throws the following errors when running build.

image

@mui/material: v5.2.0 webpack: 5.64.2 react: 17.0.2

EDIT: Seems to be related to a change in @mui/utils where an attempt is made to check for the existence of useId in react: https://github.com/mui-org/material-ui/commit/3323b23d8c5b6c03627f9c46634db3b595795433#diff-41d8fb02706e8d95b775dfa0caadade00dbbcb017d7f2c7acbc3100c5a02d46f

Expected behavior 🤔

Build should work on React 17 as v5.2.0 is a minor release and React 18, which includes these imports, is not yet released.

Steps to reproduce 🕹

Steps:

  1. Clone the following repo: https://github.com/sachinahya/mui-5.2.0-build-error
  2. Run yarn build.

To reproduce working example:

  1. Change version of @mui/material in package.json to ~5.1.0.
  2. Add the following resolutions to package.json:
"resolutions": {
  "@mui/utils": "~5.1.0"
},

Context 🔦

No response

Your environment 🌎

`npx @mui/envinfo`
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:35
  • Comments:33 (9 by maintainers)

github_iconTop GitHub Comments

11reactions
eps1loncommented, Nov 25, 2021

Should be fixed in 5.2.1. Make sure you have @mui/material@^5.2.1 and @mui/utils@^5.2.1 in your dependency tree.

10reactions
solarmosaic-colin-youngcommented, Nov 23, 2021

So, this is pretty hacky, but you should be able to resolve this temporarily/quickly while we’re still waiting for this by:

  1. Hardcoding @mui/material (and all its dependencies - I had to add all of the below in my package.json’s dependencies:
"@mui/icons-material": "5.1.1",
"@mui/material": "5.1.1",
"@mui/utils": "5.1.1",
"@mui/private-theming": "5.1.1",
"@mui/styled-engine": "5.1.1",
"@mui/system": "5.1.1",
  1. Using something like force-resolutions and adding this to package.json:
"resolutions": {
  "@mui/utils": "5.1.1",
  "@mui/material": "5.1.1",
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: "export 'useId' (imported as 'React') was not found in ...
Current behavior. Building a project on React 17 throws the following errors when running build. image. @mui/material: v5.2.0
Read more >
React is giving error: export 'useId' (imported ... - Stack Overflow
I've created a new react app using webpack. It is showing me this error I've written minimum code as of now. The code...
Read more >
React v18.0 – React Blog
React 18 is now available on npm! In our last post, we shared step-by-step instructions for upgrading your app to React 18.
Read more >
Test Utilities - React
ReactTestUtils makes it easy to test React components in the testing framework of your choice. At Facebook we use Jest for painless JavaScript...
Read more >
Invalid Hook Call Warning - React
You are probably here because you got the following error message: Hooks can only be called inside the body of a function component....
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