【发布时间】:2018-08-23 08:03:09
【问题描述】:
我通读了https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#fetching-external-data-when-props-change。我仍然无法理解为什么他们必须弃用 componentWillReceiveProps。
在 componentWillReceiveProps 中进行 ajax 调用有什么害处?一旦 ajax 调用返回值,我就会更新状态,从而重新渲染组件。
【问题讨论】:
-
我不认为 getDerivedStateFromProps 是异步的。 github.com/facebook/react/issues/13541
标签: reactjs