【发布时间】:2020-12-30 13:28:34
【问题描述】:
我是 React 新手,我正在使用最新版本的 React 了解 React 组件生命周期。我对下面部分代码的“超级”调用带有已弃用的警告标记。我很难理解这一点,因为那里的许多文档仍然使用“超级”,而且我不确定继任者是什么,即使来自反馈中链接的完整文章也是如此。有任何想法吗?谢谢。
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)
【问题讨论】:
-
可能是 React native context and deprecated super usage 的副本?这里没有
context,代码其实没问题,警告错了。
标签: reactjs typescript deprecated