React Native中的superprops是真的不推荐使用还是只是Vs代码警告?

问题描述

我在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 = {
    };
}

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...