我是React的新手,正在学习最新版本的React中的React组件生命周期。下面部分代码中我的"super"调用被标记为过时警告。我很难理解这个,因为很多文档仍然使用“super”,而且我甚至不确定它的后继者是什么,即使是从反馈中链接到的完整文章也是如此。有什么想法吗?谢谢。
class App extends Component {
constructor(props) {
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>' is deprecated ts(6385)
context
,代码实际上很好,警告是错误的。 - Bergi