【发布时间】:2017-08-09 10:08:47
【问题描述】:
https://facebook.github.io/react/docs/react-component.html#setstate
我好像官方文档说:
setState() 的第二个参数是一个可选的回调函数,一旦 setState 完成并重新渲染组件,就会执行该回调函数。通常我们建议使用 componentDidUpdate() 来代替此类逻辑。
当我们需要使用最新状态时,为什么他们建议使用 componentDidUpdate 而不是回调?
【问题讨论】:
标签: reactjs