问题描述
我在vs代码中收到了关于弃用super(props)的警告,但在警告消息中提到的链接中找不到有用的信息。
警告:
'(props: any,context?: any): Component<any,any,any>' is deprecated
@deprecated
@see — https://reactjs.org/docs/legacy-context.html
我的组件类中的构造函数:
constructor(props) {
super(props);
this.state = {
};
}
解决方法
使用此:
constructor() {
super();
this.state = {
};
}