@samitouri / QOS-React-2 / commits / 6a7f3aa858

[FeatureFlags] Enable useMemoCache for ReactTestRenderer (#27677)

## Summary Forget compiled code currently cannot be tested with ReactTestRender as `useMemoCache` is not being set on the dispatcher. This PR ensures that projects can execute unit tests with Forget compilation in the test build pipeline. ```js // source code function Component(props) { // ... } // transformed code, which also should be evaluated in unit tests function Component(props) { const $ = useMemoCache(...); // ... } ``` This PR enables the `enableUseMemoCacheHook` feature flag for all bundle variations of ReactTestRenderer. Forget *should* be the only caller of useMemoCache, so this should be a reversible change (in the event we need to change the implementation or api of the hook). ## How did you test this change? * Check that generated ReactTestRenderer bundles contain `useMemoCache`. * Synced to Meta and checked that unit tests that use Forget + @testing-library/react pass. I did not add new tests to check that useMemoCache can be called when using the test renderer as `useMemoCache` is not yet stable. Happy to add a test case here if that would be helpful to reviewers though (I'm guessing that would go in `packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js` )

mofeiZ committed Nov 10, 2023 at 10:31 UTC 6a7f3aa858b3a8670d6a4861e30f248b335e55bd
2 files changed +2 -2
packages/shared/forks/ReactFeatureFlags.test-renderer.native.js
+1 -1
@@ -46,7 +46,7 @@ export const enableGetInspectorDataForInstanceInProduction = false;
46 export const enableSuspenseAvoidThisFallback = false;
47 export const enableSuspenseAvoidThisFallbackFizz = false;
48 export const enableCPUSuspense = false;
49 -export const enableUseMemoCacheHook = false;
49 +export const enableUseMemoCacheHook = true;
50 export const enableUseEffectEventHook = false;
51 export const enableClientRenderFallbackOnTextMismatch = true;
52 export const createRootStrictEffectsByDefault = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
+1 -1
@@ -42,7 +42,7 @@ export const disableModulePatternComponents = true;
42 export const enableSuspenseAvoidThisFallback = true;
43 export const enableSuspenseAvoidThisFallbackFizz = false;
44 export const enableCPUSuspense = false;
45 -export const enableUseMemoCacheHook = false;
45 +export const enableUseMemoCacheHook = true;
46 export const enableUseEffectEventHook = false;
47 export const enableClientRenderFallbackOnTextMismatch = true;
48 export const enableComponentStackLocations = true;