wenzi0github / react

react源码的解析和学习
MIT License
17 stars 2 forks source link

what time nextWorkInProgressHook is null but nextCurrentHook not in updateWorkInProgressHook? #1

Open wenzi0github opened 2 years ago

wenzi0github commented 2 years ago

when nextWorkInProgressHook is null but nextCurrentHook not in updateWorkInProgressHook?

https://github.com/wenzi0github/react/blob/8af5b16ac8836f7950510296f276a84268e3374e/packages/react-reconciler/src/ReactFiberHooks.old.js#L721

wenzi0github commented 2 years ago

ok, I got it.

Before updateWorkInProgressHook(), it will change workInProgress.memoizedState to null, and change currentlyRenderingFiber too. That means nextWorkInProgressHook always is null when rerendered by useState().

So, I have the second question, what time nextWorkInProgressHook will be not null.