一帐要、組件生命周期的執(zhí)行次數(shù)是什么樣子的坛悉?
image.png
二坪创、組件的生命周期執(zhí)行順序是什么樣子的斥滤?
假設(shè)組件嵌套關(guān)系是 App里有parent組件,parent組件有child組件丸升。
image
如果不涉及到setState更新铆农,第一次渲染的順序如下:
image
image.png
這時(shí)候觸發(fā)App的setState事件
image
image.png
那如果是觸發(fā)parent的setState呢?
image
parent: componentWillUpdate --> render -->
child: componentWillReceiveProps --> componentWillUpdate --> render -->
componentDidUpdate (child) --> componentDidUpdate (parent)
那如果是只是觸發(fā)了child組件自身的setState呢狡耻?
image
image.png
文章內(nèi)容轉(zhuǎn)載于https://www.cnblogs.com/faith3/p/9216165.html