小编典典

为什么不应该使用componentWillMount?

reactjs

触发服务器调用以获取componentWillMount生命周期方法中的数据是一种不好的做法?

以及为什么最好使用componentDidMount。


阅读 518

收藏
2020-07-22

共1个答案

小编典典

更新: componentWillMount将很快被弃用


引用@Dan Abramov

React的未来版本中,我们期望componentWillMount 在某些情况下 会触发多次
,因此您应该对网络请求使用componentDidMount。

在这里阅读更多。

2020-07-22