Skip to content

Commit 6a7f3aa

Browse files
authored
[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` )
1 parent c4c87e0 commit 6a7f3aa

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/shared/forks/ReactFeatureFlags.test-renderer.native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const enableGetInspectorDataForInstanceInProduction = false;
4646
export const enableSuspenseAvoidThisFallback = false;
4747
export const enableSuspenseAvoidThisFallbackFizz = false;
4848
export const enableCPUSuspense = false;
49-
export const enableUseMemoCacheHook = false;
49+
export const enableUseMemoCacheHook = true;
5050
export const enableUseEffectEventHook = false;
5151
export const enableClientRenderFallbackOnTextMismatch = true;
5252
export const createRootStrictEffectsByDefault = false;

packages/shared/forks/ReactFeatureFlags.test-renderer.www.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const disableModulePatternComponents = true;
4242
export const enableSuspenseAvoidThisFallback = true;
4343
export const enableSuspenseAvoidThisFallbackFizz = false;
4444
export const enableCPUSuspense = false;
45-
export const enableUseMemoCacheHook = false;
45+
export const enableUseMemoCacheHook = true;
4646
export const enableUseEffectEventHook = false;
4747
export const enableClientRenderFallbackOnTextMismatch = true;
4848
export const enableComponentStackLocations = true;

0 commit comments

Comments
 (0)