最佳答案
我是 React 的新手,我正在学习 React 组件的生命周期和最新版本的 React。下面部分代码的“超级”调用被标记为不推荐的警告。我很难理解这个问题,因为很多文档仍然使用“ 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)