调用setState()函数时会发生什么? [英] What happens when setState() function is called?
本文介绍了调用setState()函数时会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
setState()
函数运行的是什么?它只运行 render()
?
What does the setState()
function run? Does it only run render()
?
推荐答案
setState()将按此顺序运行函数:
The setState() will run functions in this order:
shouldComponentUpdate()
componentWillUpdate()
render()
componentDidUpdate()
如果您的组件是接收道具它将使用上述函数运行 componentWillRecieveProps()
函数。
If your component is receiving props it will run the componentWillRecieveProps()
function with the above functions.
这篇关于调用setState()函数时会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文