简体   繁体   English

./src/components/styles.js 尝试导入错误:'@material-ui/core/styles' 不包含默认导出(作为 'makeStyles' 导入)

[英]./src/components/styles.js Attempted import error: '@material-ui/core/styles' does not contain a default export (imported as 'makeStyles')

I get我得到

./src/components/styles.js Attempted import error: '@material-ui/core/styles' does not contain a default export (imported as 'makeStyles'). ./src/components/styles.js 尝试导入错误:“@material-ui/core/styles”不包含默认导出(作为“makeStyles”导入)。

when I try to run my react app.当我尝试运行我的 React 应用程序时。 How would I resolve this?我将如何解决这个问题?

Here are the contents of styles.js for reference:下面是styles.js的内容供参考:

import makeStyles from "@material-ui/core/styles";从“@material-ui/core/styles”导入makeStyles;

export default makeStyles(()=>({ ul:{ justifyContent: "space-around", }, }));导出默认 makeStyles(()=>({ ul:{ justifyContent: "space-around", }, }));

You need to use a named import like this:您需要使用这样的命名导入:

import {makeStyles} from "@material-ui/core/styles"

or a default import like so,或像这样的默认导入,

import makeStyles from "@material-ui/core/styles/makeStyles"

You're in the middle of the two.你介于两者之间。

https://material-ui.com/guides/minimizing-bundle-size/#development-environment is good to read up on. https://material-ui.com/guides/minimizing-bundle-size/#development-environment很好读。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试导入错误:“makeStyles”未从“@material-ui/core/styles”导出 - Attempted import error: 'makeStyles' is not exported from '@material-ui/core/styles' @material-ui/core/styles 的问题:不包含名为“makeStyles”的导出 - problem with @material-ui/core/styles: does not contain an export named 'makeStyles' 尝试导入错误:“./components”不包含默认导出(导入为“App”) - Attempted import error: './components' does not contain a default export (imported as 'App') ./src/index.js 尝试导入错误:“./App.js”不包含默认导出(导入为“App”) - ./src/index.js Attempted import error: './App.js' does not contain a default export (imported as 'App') 与@material-ui/core 相比,@mui/styles 的 makeStyles 中的主题为空 - Theme is empty in makeStyles for @mui/styles as compared to @material-ui/core 尝试导入错误:“./components/headerComponent/header”不包含默认导出(导入为“标题”) - Attempted import error: './components/headerComponent/header' does not contain a default export (imported as 'Header') React-Redux:尝试导入错误:“./components/Score”不包含默认导出(导入为“Score”) - React-Redux: Attempted import error: './components/Score' does not contain a default export (imported as 'Score') 导入错误:在使用 @material-ui/core/styles/ThemeProvider/ 和 @material-ui/core/styles/createMuiTheme/ 时找不到模块 - import error: Module not found on using @material-ui/core/styles/ThemeProvider/ and @material-ui/core/styles/createMuiTheme/ 尝试导入错误:“./movieReducer”不包含默认导出(导入为“movieReducer”) - Attempted import error: './movieReducer' does not contain a default export (imported as 'movieReducer') [React.js] 尝试导入错误:'./registerServiceWorker' 不包含默认导出(导入为 'registerServiceWorker') - [React.js]Attempted import error: './registerServiceWorker' does not contain a default export (imported as 'registerServiceWorker')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM