super(props)这种方法即将被弃用
// 类的构造函数
constructor(props) {
super(props);
this.state = {
inputValue: 'hello world',
list: []
}
}
下面是vscode报出警告信息,大概意思是 super(props) 这种方法即将被弃用
请问一下,新的写法应该是怎样的,谢谢!
constructor React.Component<any, any, any>(props: any, context?: any): React.Component<any, any, any> (+1 overload)
@deprecated
@see — https://reactjs.org/docs/legacy-context.html
“(props: any, context?: any): Component<any, any, any>”已被弃用ts(6385)
正在回答
同学你好,老师看了链接文档,里面没有说弃用的事情,还是这样使用的

祝学习愉快!
同学你好,这边测试源码是没有问题的,官方文档中没有提到弃用的事情:
https://zh-hans.reactjs.org/docs/react-component.html#constructor
如果对项目运行不影响,可以先不用管,继续学习后面的知识。或者下载源码测试看看

祝学习愉快!
- 参与学习 人
- 提交作业 239 份
- 解答问题 10739 个
本阶段带你深入前端开发的肌理,通过ES6基础知识和前端主流高级框架的学习,助你快速构建企业级移动webAPP应用,进入职场的终极battle
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧