Skip to content

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

@sachinahya

Description

@sachinahya

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: 3323b23#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.

Metadata

Metadata

Assignees

Labels

external dependencyBlocked by external dependency, we can’t do anything about it.type: bugIt doesn't behave as expected.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions