You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionFoo(){useEffect(()=>{console.log(1);},[]);useLayoutEffect(()=>{console.log(2);},[]);useEffect(()=>{console.log(3);},[]);return<p>this is Foo</p>;}
按上述示例,挂载相关副作用 hook 后,内部逻辑结构如下:
Foo 的
fiber.memoizedState
指向第一个useEffect hook
,该hook.memoizedState
指向一个effct
对象,该对象的next
指向useLayoutEffect hook
的effect
对象;指向第一个
useEffect hook
的hook.next
指向下一个useLayoutEffect hook
;最后一个
useEffect hook
的hook.memoizedState
的effct
的next
指向第一个useEffect hook
的effct
Foo 的
fiber.updateQueue.lastEffect
指向最后一个useEffect hook
的effect
对象;不同类型的
effect.tag
(HookFlags)也不同:HasEffect
和Passive
HasEffect
和Layout
The text was updated successfully, but these errors were encountered: