facebook / react

The library for web and native user interfaces.
https://react.dev
MIT License
229.21k stars 46.94k forks source link

Suspense priority warning does not work for any hook except the first one per component #17527

Closed acdlite closed 3 years ago

acdlite commented 4 years ago

The code that checks for high priority updates only checks the first hook on the component:

https://github.com/facebook/react/blob/5064c7f6aa2b46469ac601cc851640e91ec340a9/packages/react-reconciler/src/ReactFiberWorkLoop.js#L2889-L2891

workInProgress.memoizedState is the first hook.

It should loop through all the hooks instead:

let firstHook = workInProgress.memoizedState;
if (firstHook !==  null) {
  let hook = firstHook;
  do {
    // Stuff goes here
    hook = hook.next;
  } while (hook !== firstHook)
}
gaearon commented 3 years ago

The warning is gone.