无效的挂钩调用导致页面崩溃

时间:2020-08-19 07:09:59

标签: reactjs material-ui react-hooks

我有点反感,并在功能组件中使用了“反应粘性表”。一切似乎都很好,并按预期工作。但是现在页面突然崩溃说。

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会使页面崩溃。 注意:为了简单起见,我将代码截断了。

0 个答案:

没有答案