Fix ownerStackLimit feature gating for tests (#32726)
https://github.com/facebook/react/pull/32529 added a dynamic flag for this, but that breaks tests since the flags are not defined everywhere. However, this is a static value and the flag is only for supporting existing tests. So we can override it in the test config, and make it static at built time instead.
Ricky committed
Mar 26, 2025 at 12:01 UTC
f99c9feaf786fbdad0ad8d2d81196a247302dd3c
6 files changed
+9
-11
packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js
-4
@@ -29,7 +29,3 @@ export const enableUseEffectCRUDOverload = __VARIANT__;
29
export const enableFastAddPropertiesInDiffing = __VARIANT__;
30
export const enableLazyPublicInstanceInFabric = __VARIANT__;
31
export const renameElementSymbol = __VARIANT__;
32
-export const ownerStackLimit: number = __VARIANT__
33
- ? // Some value that doesn't impact existing tests
34
- 500
35
- : 1e4;
packages/shared/forks/ReactFeatureFlags.native-fb.js
+1
-1
@@ -31,7 +31,6 @@ export const {
31
enableFastAddPropertiesInDiffing,
32
enableLazyPublicInstanceInFabric,
33
renameElementSymbol,
34
- ownerStackLimit,
34
} = dynamicFlags;
35
36
// The rest of the flags are static for better dead code elimination.
@@ -85,6 +84,7 @@ export const enableViewTransition = false;
84
export const enableSwipeTransition = false;
85
export const enableScrollEndPolyfill = true;
86
export const enableFragmentRefs = false;
87
+export const ownerStackLimit = 1e4;
88
89
// Flow magic to verify the exports of this file match the original version.
90
((((null: any): ExportsType): FeatureFlagsType): ExportsType);
packages/shared/forks/ReactFeatureFlags.www-dynamic.js
-5
@@ -43,11 +43,6 @@ export const enableComponentPerformanceTrack = __VARIANT__;
43
export const enableScrollEndPolyfill = __VARIANT__;
44
export const enableFragmentRefs = __VARIANT__;
45
46
-export const ownerStackLimit: number = __VARIANT__
47
- ? // Some value that doesn't impact existing tests
48
- 500
49
- : 1e4;
50
-
46
// TODO: These flags are hard-coded to the default values used in open source.
47
// Update the tests so that they pass in either mode, then set these
48
// to __VARIANT__.
packages/shared/forks/ReactFeatureFlags.www.js
+2
-1
@@ -40,7 +40,6 @@ export const {
40
enableComponentPerformanceTrack,
41
enableScrollEndPolyfill,
42
enableFragmentRefs,
43
- ownerStackLimit,
43
} = dynamicFeatureFlags;
44
45
// On WWW, __EXPERIMENTAL__ is used for a new modern build.
@@ -115,5 +114,7 @@ export const enableLazyPublicInstanceInFabric = false;
114
115
export const enableSwipeTransition = false;
116
117
+export const ownerStackLimit = 1e4;
118
+
119
// Flow magic to verify the exports of this file match the original version.
120
((((null: any): ExportsType): FeatureFlagsType): ExportsType);
scripts/jest/setupTests.www.js
+3
@@ -17,6 +17,9 @@ jest.mock('shared/ReactFeatureFlags', () => {
17
// we remove the flag.
18
actual.disableClientCache = __VARIANT__;
19
20
+ // Some value that doesn't impact existing tests
21
+ actual.ownerStackLimit = __VARIANT__ ? 500 : 1e4;
22
+
23
return actual;
24
});
25
scripts/jest/setupTests.xplat.js
+3
@@ -22,6 +22,9 @@ jest.mock('shared/ReactFeatureFlags', () => {
22
actual.enableScopeAPI = true;
23
actual.enableTaint = false;
24
25
+ // Some value that doesn't impact existing tests
26
+ actual.ownerStackLimit = __VARIANT__ ? 500 : 1e4;
27
+
28
return actual;
29
});
30