reactjs - Cant import Table Container in ReactJS - Material UI
问题描述
I am trying to create a table component but cant import TableContainer Component from material-ui:
Attempted import error: 'TableContainer' is not exported from '@material-ui/core'.
I require it at the top of the page like this:
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { TableRow, TableHead, TableContainer, TableCell, TableBody, Table, Paper } from '@material-ui/core';
And here is my package.json and i tried npm install && npm update too.
{
"name": "link_validator",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.8.0",
"@material-ui/icons": "^4.5.1",
"@material-ui/styles": "^4.7.1",
"@material/button": "^4.0.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-redux": "^7.1.3",
"react-scripts": "^3.3.0",
"redux": "^4.0.4",
"styled-components": "^4.4.1",
"typescript": "^3.7.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
解决方案
正如@AtinSingh 建议的那样,我尝试npm卸载并再次安装,将最新的写入package.json +导入而不进行解构,它起作用了。
推荐阅读
- javascript - 这种情况的最佳动画选项
- flutter - 如何与 ListView 分开显示项目
- centos - RHEL 7.2 yum install openssl-devel 错误
- python - 如何并行编写 2 个 Python 装饰器
- node.js - 使用 switch 语句添加对消息的反应
- typescript - react-query 如何使用 useInfiniteQuery?
- vue.js - 部署到 Google App Engine 后,Safari 中的键盘导航消失了
- alignment - div内双元素的水平居中
- python - 通用文件操作的多线程或多处理?
- java - Spring Cacheable返回对象的副本