reactjs - TypeError:dispatcher.useDebugValue 不是函数
问题描述
刚开始学习react。我不知道很多基本的东西,所以我们开始吧。
我正在尝试实现在 react material-ui 上找到的表格示例。
得到以下代码:
import { makeStyles } from '@material-ui/core/styles';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
import TableContainer from '@material-ui/core/TableContainer';
import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow';
import Paper from '@material-ui/core/Paper';
const useStyles = makeStyles({
table: {
minWidth: 650,
},
});
function createData(name, calories, fat, carbs, protein) {
return { name, calories, fat, carbs, protein };
}
const rows = [
createData('Frozen yoghurt', 159, 6.0, 24, 4.0),
createData('Ice cream sandwich', 237, 9.0, 37, 4.3),
createData('Eclair', 262, 16.0, 24, 6.0),
createData('Cupcake', 305, 3.7, 67, 4.3),
createData('Gingerbread', 356, 16.0, 49, 3.9),
];
export default function BasicTable() {
const classes = useStyles();
return (
<TableContainer component={Paper}>
<Table className={classes.table} aria-label="simple table">
<TableHead>
<TableRow>
<TableCell>Dessert (100g serving)</TableCell>
<TableCell align="right">Calories</TableCell>
<TableCell align="right">Fat (g)</TableCell>
<TableCell align="right">Carbs (g)</TableCell>
<TableCell align="right">Protein (g)</TableCell>
</TableRow>
</TableHead>
<TableBody>
{rows.map((row) => (
<TableRow key={row.name}>
<TableCell component="th" scope="row">
{row.name}
</TableCell>
<TableCell align="right">{row.calories}</TableCell>
<TableCell align="right">{row.fat}</TableCell>
<TableCell align="right">{row.carbs}</TableCell>
<TableCell align="right">{row.protein}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
);
}
然后我收到以下错误:
有人可以告诉我这是为什么吗?
更新:我必须将 react 和 react-dom 都更新到最新版本
解决方案
我复制了你的代码,添加了import React from 'react'
,一切正常
推荐阅读
- r - 创建一个在其他列中查找值的新列
- sql - 将转换后的格式更改为 ISO 日期 - SQL Server
- javascript - 使用 javascript 创建带有图像标签的数组
- angular - 组件组成 - 验证问题
- asp.net-core - favicon.ico 503 文本/html
- c++ - 使用指针和向量时没有运算符匹配“*”错误
- docker - 为什么我必须定期使用 `docker network prune` 来重新启用容器内的 docker 映射 ip 连接?
- android - MotionLayout 和 Horizontal Recyclerview
- android - Android 铬错误
- kotlin - Kotlin 多类数据存储