简体   繁体   中英

Attempted import error: 'useControlled' is not exported from '@material-ui/core/utils'

./node_modules/@material-ui/lab/esm/useAutocomplete/useAutocomplete.js 
Attempted import error: 'useControlled' is not exported from '@material-ui/core/utils'.

Facing this issue , how to fix ?

corresponding versions

"@material-ui/core": "^4.8.3",
"@material-ui/lab": "^4.0.0-alpha.44",

Link for the component which i am using

You're using the latest version of the lab, but an older version of core. Switch to 4.9.4 for core and it should be fine.

missing some path

Your import statement should be

import useControlled from '@material-ui/core/utils/useControlled'

There is no index file in utils.

Changing the the version of the packages didn't work for me. The issue was with the refrencing path in the import statement.

replace

import Autocomplete from "@material-ui/lab";

with

import Autocomplete from "@material-ui/lab/Autocomplete";

try updating @material-ui/core by running

npm update

这可能对您有用:

import { useControlled } from '@mui/material';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM