reactjs - React Native 中的 super(props) 真的被弃用了还是只是一个 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 = {
};
}
推荐阅读
- ffmpeg - 当我将视频转换为图像时,ffmpeg 停止
- ibm-cloud - 在 IBM Cloud 中生成密钥和 CSR
- emacs - Spacemacs neo 树的所有图标都无法在窗口 10 上运行
- vue.js - 复制一个select元素并动态添加v-model
- java - 在打开新活动之前等待旋转动画在 android 中完成?
- sql - SQL从列中查找大写单词
- objective-c - macOS 中并发的替代方案:: 数据结构
- git - 如何使用凭据从 Lan 的 PC 克隆 Git 存储库
- javascript - 无法读取未定义的属性“onDeleteClick”
- consul - 领事没有显示在不同节点注册的服务