dillon1000/react
Commit
Browse files Reuse hooks when replaying a suspended component
When a component suspends, under some conditions, we can wait for the data to resolve and replay the component without unwinding the stack or showing a fallback in the interim. When we do this, we reuse the promises that were unwrapped during the previous attempts, so that if they aren't memoized, the result can still be used. We should do the same for all hooks. That way, if you _do_ memoize an async function call with useMemo, it won't be called again during the replay. This effectively gives you a local version of the functionality provided by `cache`, using the normal memoization patterns that have long existed in React.
Changed paths7 files
First-parent comparisonpackages/react-reconciler/src/ReactFiberBeginWork.new.js ModifiedM packages/react-reconciler/src/ReactFiberBeginWork.old.js ModifiedM packages/react-reconciler/src/ReactFiberHooks.new.js ModifiedM packages/react-reconciler/src/ReactFiberHooks.old.js ModifiedM packages/react-reconciler/src/ReactFiberWorkLoop.new.js ModifiedM packages/react-reconciler/src/ReactFiberWorkLoop.old.js ModifiedM packages/react-reconciler/src/__tests__/ReactThenable-test.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…