mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
eb67bf1b96f8e38918fd1238a4ccd1791823e19c
Fixes the bug that @alexmckenley and @mofeiZ found where setState-in-render can reset useMemoCache and cause an infinite loop. The bug was that renderWithHooksAgain() was not resetting hook state when rerendering (so useMemo values were preserved) but was resetting the updateQueue. This meant that the entire memo cache was cleared on a setState-in-render. The fix here is to call a new helper function to clear the update queue. It nulls out other properties, but for memoCache it just sets the index back to zero. ghstack-source-id:fc0947ce21Pull Request resolved: https://github.com/facebook/react/pull/30889 DiffTrain build for [727b361528](https://github.com/facebook/react/commit/727b3615287074ddaa28069bfbd2dfee8cf73575)
Please do not delete this branch
Description
Languages
JavaScript
67.1%
TypeScript
29.4%
HTML
1.5%
CSS
1.1%
C++
0.6%
Other
0.2%