在我现有的项目中,我使用了componentWillMount()。现在它被弃用了。所以我该怎么做?

问题描述 投票:0回答:1

Reajctjs官方文档称componentWillMount()已被弃用。使用时不安全。所以在我目前的直播项目中,我已经在很多容器中使用过它。 willenter image description here有没有机会破坏我的生产系统?请告知,谢谢。

reactjs react-native react-redux containers
1个回答
1
投票

正如docs中提到的那样

此生命周期之前被命名为componentWillMount。该名称将继续有效,直到版本17。

您可以手动或使用react-codemod在此之前转换文件

© www.soinside.com 2019 - 2024. All rights reserved.