Error: "export 'useId' (imported as 'React') was not found in 'react'" after upgrading to v5.2.0
See original GitHub issueDuplicates
- 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.
@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:
- Clone the following repo: https://github.com/sachinahya/mui-5.2.0-build-error
- Run
yarn build
.
To reproduce working example:
- Change version of
@mui/material
in package.json to~5.1.0
. - 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:
- Created 2 years ago
- Reactions:35
- Comments:33 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.So, this is pretty hacky, but you should be able to resolve this temporarily/quickly while we’re still waiting for this by:
@mui/material
(and all its dependencies - I had to add all of the below in mypackage.json
’sdependencies
:package.json
: