www: make disableLegacyMode dynamic flag (#29774)
This makes the flag dynamic for Meta and turns it on for the www test renderer.
Jan Kassens committed
Jun 7, 2024 at 07:36 UTC
142b2a8230130ddf3de8a9c8e7799a291f4d1a97
5 files changed
+13
-11
packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js
+1
-1
@@ -373,7 +373,7 @@ describe('ReactComponentLifeCycle', () => {
373
expect(instance.updater.isMounted(instance)).toBe(false);
374
});
375
376
- // @gate www && !disableLegacyMode
376
+ // @gate www && classic
377
it('warns if legacy findDOMNode is used inside render', async () => {
378
class Component extends React.Component {
379
state = {isMounted: false};
packages/react-dom/src/__tests__/findDOMNodeFB-test.js
+8
-8
@@ -14,12 +14,12 @@ const ReactDOM = require('react-dom');
14
const StrictMode = React.StrictMode;
15
16
describe('findDOMNode', () => {
17
- // @gate www && !disableLegacyMode
17
+ // @gate www && classic
18
it('findDOMNode should return null if passed null', () => {
19
expect(ReactDOM.findDOMNode(null)).toBe(null);
20
});
21
22
- // @gate www && !disableLegacyMode
22
+ // @gate www && classic && !disableLegacyMode
23
it('findDOMNode should find dom element', () => {
24
class MyNode extends React.Component {
25
render() {
@@ -39,7 +39,7 @@ describe('findDOMNode', () => {
39
expect(mySameDiv).toBe(myDiv);
40
});
41
42
- // @gate www && !disableLegacyMode
42
+ // @gate www && classic && !disableLegacyMode
43
it('findDOMNode should find dom element after an update from null', () => {
44
function Bar({flag}) {
45
if (flag) {
@@ -66,14 +66,14 @@ describe('findDOMNode', () => {
66
expect(b.tagName).toBe('SPAN');
67
});
68
69
- // @gate www && !disableLegacyMode
69
+ // @gate www && classic
70
it('findDOMNode should reject random objects', () => {
71
expect(function () {
72
ReactDOM.findDOMNode({foo: 'bar'});
73
}).toThrowError('Argument appears to not be a ReactComponent. Keys: foo');
74
});
75
76
- // @gate www && !disableLegacyMode
76
+ // @gate www && classic && !disableLegacyMode
77
it('findDOMNode should reject unmounted objects with render func', () => {
78
class Foo extends React.Component {
79
render() {
@@ -90,7 +90,7 @@ describe('findDOMNode', () => {
90
);
91
});
92
93
- // @gate www && !disableLegacyMode
93
+ // @gate www && classic && !disableLegacyMode
94
it('findDOMNode should not throw an error when called within a component that is not mounted', () => {
95
class Bar extends React.Component {
96
UNSAFE_componentWillMount() {
@@ -107,7 +107,7 @@ describe('findDOMNode', () => {
107
}).not.toThrow();
108
});
109
110
- // @gate www && !disableLegacyMode
110
+ // @gate www && classic && !disableLegacyMode
111
it('findDOMNode should warn if used to find a host component inside StrictMode', () => {
112
let parent = undefined;
113
let child = undefined;
@@ -141,7 +141,7 @@ describe('findDOMNode', () => {
141
expect(match).toBe(child);
142
});
143
144
- // @gate www && !disableLegacyMode
144
+ // @gate www && classic && !disableLegacyMode
145
it('findDOMNode should warn if passed a component that is inside StrictMode', () => {
146
let parent = undefined;
147
let child = undefined;
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
+1
-1
@@ -84,7 +84,7 @@ export const disableStringRefs = false;
84
export const enableFastJSX = false;
85
86
export const enableReactTestRendererWarning = false;
87
-export const disableLegacyMode = false;
87
+export const disableLegacyMode = true;
88
89
export const disableDefaultPropsExceptForClasses = false;
90
export const enableAddPropertiesFastPath = false;
packages/shared/forks/ReactFeatureFlags.www-dynamic.js
+1
@@ -32,6 +32,7 @@ export const retryLaneExpirationMs = 5000;
32
export const syncLaneExpirationMs = 250;
33
export const transitionLaneExpirationMs = 5000;
34
export const enableAddPropertiesFastPath = __VARIANT__;
35
+export const disableLegacyMode = __VARIANT__;
36
37
// Enable this flag to help with concurrent mode debugging.
38
// It logs information to the console about React scheduling, rendering, and commit phases.
packages/shared/forks/ReactFeatureFlags.www.js
+2
-1
@@ -119,7 +119,8 @@ export const useModernStrictMode = true;
119
// because JSX is an extremely hot path.
120
export const disableStringRefs = false;
121
122
-export const disableLegacyMode = __EXPERIMENTAL__;
122
+export const disableLegacyMode: boolean =
123
+ __EXPERIMENTAL__ || dynamicFeatureFlags.disableLegacyMode;
124
125
export const enableOwnerStacks = false;
126
export const enableShallowPropDiffing = false;