mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
b41f0cd50dc9f000bf66609d2d3cafe71c727de7
Stacked on https://github.com/facebook/react/pull/30662.
Alternative to https://github.com/facebook/react/pull/30663 and
https://github.com/facebook/react/pull/30677.
During a Fast Refresh, we always want to evict the memo cache, same as
we do with normal `useMemo`. The mechanism used by `useMemo` and other
Hooks is this module-level variable:
https://github.com/facebook/react/blob/fca5d655d78917400a2722287351c20938166669/packages/react-reconciler/src/ReactFiberHooks.js#L304-L307
which has DEV-only behavior as if the dependencies are always different:
https://github.com/facebook/react/blob/fca5d655d78917400a2722287351c20938166669/packages/react-reconciler/src/ReactFiberHooks.js#L451-L460
The `useMemoCache` Hook doesn't use a dependency array but conceptually
I think we want the same behavior.
## Test Plan
The test passes.
---------
Co-authored-by: Lauren Tan <poteto@users.noreply.github.com>
DiffTrain build for [7e8a06cf4c](https://github.com/facebook/react/commit/7e8a06cf4c628be45171da52c1a8e97f9869b7ee)
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%