老师,我写的时候报了个错

来源:8-6 【订阅state】store的连接与订阅

小奶猫不想来吃瓜

2023-09-11

Can’t call setState on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to this.state directly or define a state = {}; class property with the desired state in the HeaderComponent component.

写回答

1回答

阿莱克斯刘

2024-03-26

应该在构造方法中声明(初始化)一下state。不好意思,没看到这个问题,这么久才回答

0
0

React18 系统精讲 结合TS打造旅游电商平台

React18 精讲 + 结合 TS 实战 + 热门业务开发,获取必备技能

1993 学习 · 1015 问题

查看课程