reactjs - 无效的钩子调用导致页面崩溃
问题描述
我对在功能组件中做出反应和使用“react-sticky-table”有点陌生。一切似乎都很好,并且按预期工作。但是现在突然页面崩溃说。
Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
下面是我的代码。
class Form extends Component {
constructor(props) {
super(props);
this.state = {}
}
render() {
return (
<div>
<div style={{ width: "100%", height: "400px" }}>
<StickyTable>
<Row>
<Cell>Header 1</Cell>
<Cell>Header 2</Cell>
</Row>
<Row>
<Cell>Cell 1</Cell>
<Cell>Cell 2</Cell>
</Row>
</StickyTable>
</div>
</div>
);
}
}
export default connect(
(storeState) => ({
result: storeState.result,
}),
{
resetSubmit,
}
)(Form);
所以这里只有 StickyTable 会导致页面崩溃。注意:为简单起见,我截断了代码。
解决方案
推荐阅读
- javascript - 通过具有附加约束的多个属性对对象数组进行排序
- flutter - 减少和集中文本字段
- mysql - 当“only_full_group_by”打开时,如何按月(从日期字段)对条目进行分组?
- mysql - 将 WSL2 上的 Laravel 应用程序与 Windows 上的数据库连接起来
- asp.net-core - ASP.NET Core 中的 Azure Active Directory
- apache-spark - 通过 Apache Livy 提交的 PySpark 批处理作业的配置无效
- scala - AnyVal 和 Opaque 类型不能派生 derivings.Mirror?
- r - 使用 R studio 从 NC 文件中提取数据
- python - 如何让海龟程序在运行前等待用户的事件/响应?
- timeout - 从 shell 脚本执行 wget 命令时出现 504 超时