dillon1000/react
Commit
Browse files [Fast Refresh] Make edits to a memo comparison function take effect (#36964)
Editing the second argument of memo() previously never took effect until something else remounted the tree, for two separate reasons: - When adding a comparison function, we need to switch from SimpleMemoComponent to MemoComponent so canPreserveStateBetween should return false. - MemoComponent was missing from the hot reload type resolution in createWorkInProgress, so existing fibers kept reading .compare from the old memo object forever. New behavior: - Adding or removing the comparison function remounts; we need to do this when adding (SimpleMemoComponent doesn't support a comparison function) so let's also do it when removing. - Editing the comparison function implementation applies in place with state preserved The TODO in isCompatibleFamilyForHotReloading is removed as that wasn't the right place to do this check.
Changed paths4 files
First-parent comparisonpackages/react-reconciler/src/ReactFiber.js ModifiedM packages/react-reconciler/src/ReactFiberHotReloading.js ModifiedM packages/react-refresh/src/ReactFreshRuntime.js ModifiedM packages/react-refresh/src/__tests__/ReactFresh-test.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…