[cleanup] remove feature flags warnAboutDefaultPropsOnFunctionComponents and warnAboutStringRefs (#25980)
These feature flags are fully rolled out and easy to clean up. Let's remove them!
Jan Kassens committed
Jan 11, 2023 at 12:19 UTC
0fce6bb498357feb4465859912004b2e20fe7084
20 files changed
+111
-225
packages/react-dom/src/__tests__/ReactComponent-test.js
+14
-20
@@ -12,7 +12,6 @@
12
let React;
13
let ReactDOM;
14
let ReactDOMServer;
15
-let ReactFeatureFlags;
15
let ReactTestUtils;
16
17
describe('ReactComponent', () => {
@@ -22,7 +21,6 @@ describe('ReactComponent', () => {
21
React = require('react');
22
ReactDOM = require('react-dom');
23
ReactDOMServer = require('react-dom/server');
25
- ReactFeatureFlags = require('shared/ReactFeatureFlags');
24
ReactTestUtils = require('react-dom/test-utils');
25
});
26
@@ -137,24 +135,20 @@ describe('ReactComponent', () => {
135
136
expect(() => {
137
ReactTestUtils.renderIntoDocument(<Component />);
140
- }).toErrorDev(
141
- ReactFeatureFlags.warnAboutStringRefs
142
- ? [
143
- 'Warning: Component "div" contains the string ref "inner". ' +
144
- 'Support for string refs will be removed in a future major release. ' +
145
- 'We recommend using useRef() or createRef() instead. ' +
146
- 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
147
- ' in div (at **)\n' +
148
- ' in Wrapper (at **)\n' +
149
- ' in Component (at **)',
150
- 'Warning: Component "Component" contains the string ref "outer". ' +
151
- 'Support for string refs will be removed in a future major release. ' +
152
- 'We recommend using useRef() or createRef() instead. ' +
153
- 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
154
- ' in Component (at **)',
155
- ]
156
- : [],
157
- );
138
+ }).toErrorDev([
139
+ 'Warning: Component "div" contains the string ref "inner". ' +
140
+ 'Support for string refs will be removed in a future major release. ' +
141
+ 'We recommend using useRef() or createRef() instead. ' +
142
+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
143
+ ' in div (at **)\n' +
144
+ ' in Wrapper (at **)\n' +
145
+ ' in Component (at **)',
146
+ 'Warning: Component "Component" contains the string ref "outer". ' +
147
+ 'Support for string refs will be removed in a future major release. ' +
148
+ 'We recommend using useRef() or createRef() instead. ' +
149
+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
150
+ ' in Component (at **)',
151
+ ]);
152
});
153
154
it('should not have string refs on unmounted components', () => {
packages/react-dom/src/__tests__/ReactDOMServerIntegrationRefs-test.js
+7
-13
@@ -14,7 +14,6 @@ const ReactDOMServerIntegrationUtils = require('./utils/ReactDOMServerIntegratio
14
let React;
15
let ReactDOM;
16
let ReactDOMServer;
17
-let ReactFeatureFlags;
17
let ReactTestUtils;
18
19
function initModules() {
@@ -23,7 +22,6 @@ function initModules() {
22
React = require('react');
23
ReactDOM = require('react-dom');
24
ReactDOMServer = require('react-dom/server');
26
- ReactFeatureFlags = require('shared/ReactFeatureFlags');
25
ReactTestUtils = require('react-dom/test-utils');
26
27
// Make them available to the helpers.
@@ -99,17 +97,13 @@ describe('ReactDOMServerIntegration', () => {
97
root,
98
true,
99
);
102
- }).toErrorDev(
103
- ReactFeatureFlags.warnAboutStringRefs
104
- ? [
105
- 'Warning: Component "RefsComponent" contains the string ref "myDiv". ' +
106
- 'Support for string refs will be removed in a future major release. ' +
107
- 'We recommend using useRef() or createRef() instead. ' +
108
- 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
109
- ' in RefsComponent (at **)',
110
- ]
111
- : [],
112
- );
100
+ }).toErrorDev([
101
+ 'Warning: Component "RefsComponent" contains the string ref "myDiv". ' +
102
+ 'Support for string refs will be removed in a future major release. ' +
103
+ 'We recommend using useRef() or createRef() instead. ' +
104
+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
105
+ ' in RefsComponent (at **)',
106
+ ]);
107
expect(component.refs.myDiv).toBe(root.firstChild);
108
});
109
});
packages/react-dom/src/__tests__/refs-test.js
+39
-53
@@ -123,28 +123,24 @@ describe('reactiverefs', () => {
123
let testRefsComponent;
124
expect(() => {
125
testRefsComponent = ReactDOM.render(<TestRefsComponent />, container);
126
- }).toErrorDev(
127
- ReactFeatureFlags.warnAboutStringRefs
128
- ? [
129
- 'Warning: Component "div" contains the string ref "resetDiv". ' +
130
- 'Support for string refs will be removed in a future major release. ' +
131
- 'We recommend using useRef() or createRef() instead. ' +
132
- 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
133
- ' in div (at **)\n' +
134
- ' in TestRefsComponent (at **)',
135
- 'Warning: Component "span" contains the string ref "clickLog0". ' +
136
- 'Support for string refs will be removed in a future major release. ' +
137
- 'We recommend using useRef() or createRef() instead. ' +
138
- 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
139
- ' in span (at **)\n' +
140
- ' in ClickCounter (at **)\n' +
141
- ' in div (at **)\n' +
142
- ' in GeneralContainerComponent (at **)\n' +
143
- ' in div (at **)\n' +
144
- ' in TestRefsComponent (at **)',
145
- ]
146
- : [],
147
- );
126
+ }).toErrorDev([
127
+ 'Warning: Component "div" contains the string ref "resetDiv". ' +
128
+ 'Support for string refs will be removed in a future major release. ' +
129
+ 'We recommend using useRef() or createRef() instead. ' +
130
+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
131
+ ' in div (at **)\n' +
132
+ ' in TestRefsComponent (at **)',
133
+ 'Warning: Component "span" contains the string ref "clickLog0". ' +
134
+ 'Support for string refs will be removed in a future major release. ' +
135
+ 'We recommend using useRef() or createRef() instead. ' +
136
+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
137
+ ' in span (at **)\n' +
138
+ ' in ClickCounter (at **)\n' +
139
+ ' in div (at **)\n' +
140
+ ' in GeneralContainerComponent (at **)\n' +
141
+ ' in div (at **)\n' +
142
+ ' in TestRefsComponent (at **)',
143
+ ]);
144
145
expect(testRefsComponent instanceof TestRefsComponent).toBe(true);
146
@@ -349,17 +345,13 @@ describe('ref swapping', () => {
345
let a;
346
expect(() => {
347
a = ReactTestUtils.renderIntoDocument(<A />);
352
- }).toErrorDev(
353
- ReactFeatureFlags.warnAboutStringRefs
354
- ? [
355
- 'Warning: Component "A" contains the string ref "1". ' +
356
- 'Support for string refs will be removed in a future major release. ' +
357
- 'We recommend using useRef() or createRef() instead. ' +
358
- 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
359
- ' in A (at **)',
360
- ]
361
- : [],
362
- );
348
+ }).toErrorDev([
349
+ 'Warning: Component "A" contains the string ref "1". ' +
350
+ 'Support for string refs will be removed in a future major release. ' +
351
+ 'We recommend using useRef() or createRef() instead. ' +
352
+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
353
+ ' in A (at **)',
354
+ ]);
355
expect(a.refs[1].nodeName).toBe('DIV');
356
});
357
@@ -546,18 +538,14 @@ describe('strings refs across renderers', () => {
538
let inst;
539
expect(() => {
540
inst = ReactDOM.render(<Parent />, div1);
549
- }).toErrorDev(
550
- ReactFeatureFlags.warnAboutStringRefs
551
- ? [
552
- 'Warning: Component "Indirection" contains the string ref "child1". ' +
553
- 'Support for string refs will be removed in a future major release. ' +
554
- 'We recommend using useRef() or createRef() instead. ' +
555
- 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
556
- ' in Indirection (at **)\n' +
557
- ' in Parent (at **)',
558
- ]
559
- : [],
560
- );
541
+ }).toErrorDev([
542
+ 'Warning: Component "Indirection" contains the string ref "child1". ' +
543
+ 'Support for string refs will be removed in a future major release. ' +
544
+ 'We recommend using useRef() or createRef() instead. ' +
545
+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
546
+ ' in Indirection (at **)\n' +
547
+ ' in Parent (at **)',
548
+ ]);
549
550
// Only the first ref has rendered yet.
551
expect(inst.refs.child1.tagName).toBe('DIV');
@@ -567,14 +555,12 @@ describe('strings refs across renderers', () => {
555
// Now both refs should be rendered.
556
ReactDOM.render(<Parent />, div1);
557
}).toErrorDev(
570
- ReactFeatureFlags.warnAboutStringRefs
571
- ? [
572
- 'Warning: Component "Root" contains the string ref "child2". ' +
573
- 'Support for string refs will be removed in a future major release. ' +
574
- 'We recommend using useRef() or createRef() instead. ' +
575
- 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',
576
- ]
577
- : [],
558
+ [
559
+ 'Warning: Component "Root" contains the string ref "child2". ' +
560
+ 'Support for string refs will be removed in a future major release. ' +
561
+ 'We recommend using useRef() or createRef() instead. ' +
562
+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',
563
+ ],
564
{withoutStack: true},
565
);
566
expect(inst.refs.child1.tagName).toBe('DIV');
packages/react-reconciler/src/ReactChildFiber.js
+9
-25
@@ -28,7 +28,6 @@ import {
28
} from 'shared/ReactSymbols';
29
import {ClassComponent, HostText, HostPortal, Fragment} from './ReactWorkTags';
30
import isArray from 'shared/isArray';
31
-import {warnAboutStringRefs} from 'shared/ReactFeatureFlags';
31
import {checkPropStringCoercion} from 'shared/CheckStringCoercion';
32
33
import {
@@ -40,7 +39,6 @@ import {
39
createFiberFromPortal,
40
} from './ReactFiber';
41
import {isCompatibleFamilyForHotReloading} from './ReactFiberHotReloading';
43
-import {StrictLegacyMode} from './ReactTypeOfMode';
42
import {getIsHydrating} from './ReactFiberHydrationContext';
43
import {pushTreeFork} from './ReactFiberTreeContext';
44
@@ -113,10 +111,7 @@ function coerceRef(
111
typeof mixedRef !== 'object'
112
) {
113
if (__DEV__) {
116
- // TODO: Clean this up once we turn on the string ref warning for
117
- // everyone, because the strict mode case will no longer be relevant
114
if (
119
- (returnFiber.mode & StrictLegacyMode || warnAboutStringRefs) &&
115
// We warn in ReactElement.js if owner and self are equal for string refs
116
// because these cannot be automatically converted to an arrow function
117
// using a codemod. Therefore, we don't have to warn about string refs again.
@@ -138,26 +133,15 @@ function coerceRef(
133
const componentName =
134
getComponentNameFromFiber(returnFiber) || 'Component';
135
if (!didWarnAboutStringRefs[componentName]) {
141
- if (warnAboutStringRefs) {
142
- console.error(
143
- 'Component "%s" contains the string ref "%s". Support for string refs ' +
144
- 'will be removed in a future major release. We recommend using ' +
145
- 'useRef() or createRef() instead. ' +
146
- 'Learn more about using refs safely here: ' +
147
- 'https://reactjs.org/link/strict-mode-string-ref',
148
- componentName,
149
- mixedRef,
150
- );
151
- } else {
152
- console.error(
153
- 'A string ref, "%s", has been found within a strict mode tree. ' +
154
- 'String refs are a source of potential bugs and should be avoided. ' +
155
- 'We recommend using useRef() or createRef() instead. ' +
156
- 'Learn more about using refs safely here: ' +
157
- 'https://reactjs.org/link/strict-mode-string-ref',
158
- mixedRef,
159
- );
160
- }
136
+ console.error(
137
+ 'Component "%s" contains the string ref "%s". Support for string refs ' +
138
+ 'will be removed in a future major release. We recommend using ' +
139
+ 'useRef() or createRef() instead. ' +
140
+ 'Learn more about using refs safely here: ' +
141
+ 'https://reactjs.org/link/strict-mode-string-ref',
142
+ componentName,
143
+ mixedRef,
144
+ );
145
didWarnAboutStringRefs[componentName] = true;
146
}
147
}
packages/react-reconciler/src/ReactFiberBeginWork.js
+2
-9
@@ -97,7 +97,6 @@ import {
97
disableModulePatternComponents,
98
enableProfilerCommitHooks,
99
enableProfilerTimer,
100
- warnAboutDefaultPropsOnFunctionComponents,
100
enableScopeAPI,
101
enableCache,
102
enableLazyContextPropagation,
@@ -506,10 +505,7 @@ function updateMemoComponent(
505
getComponentNameFromType(type),
506
);
507
}
509
- if (
510
- warnAboutDefaultPropsOnFunctionComponents &&
511
- Component.defaultProps !== undefined
512
- ) {
508
+ if (Component.defaultProps !== undefined) {
509
const componentName = getComponentNameFromType(type) || 'Unknown';
510
if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
511
console.error(
@@ -2058,10 +2054,7 @@ function validateFunctionComponentInDev(workInProgress: Fiber, Component: any) {
2054
}
2055
}
2056
2061
- if (
2062
- warnAboutDefaultPropsOnFunctionComponents &&
2063
- Component.defaultProps !== undefined
2064
- ) {
2057
+ if (Component.defaultProps !== undefined) {
2058
const componentName = getComponentNameFromType(Component) || 'Unknown';
2059
2060
if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js
+7
-13
@@ -11,7 +11,6 @@
11
'use strict';
12
13
let React;
14
-let ReactFeatureFlags;
14
let ReactNoop;
15
let Scheduler;
16
@@ -20,7 +19,6 @@ describe('ReactIncrementalSideEffects', () => {
19
jest.resetModules();
20
21
React = require('react');
23
- ReactFeatureFlags = require('shared/ReactFeatureFlags');
22
ReactNoop = require('react-noop-renderer');
23
Scheduler = require('scheduler');
24
});
@@ -1310,17 +1308,13 @@ describe('ReactIncrementalSideEffects', () => {
1308
ReactNoop.render(<Foo />);
1309
expect(() => {
1310
expect(Scheduler).toFlushWithoutYielding();
1313
- }).toErrorDev(
1314
- ReactFeatureFlags.warnAboutStringRefs
1315
- ? [
1316
- 'Warning: Component "Foo" contains the string ref "bar". ' +
1317
- 'Support for string refs will be removed in a future major release. ' +
1318
- 'We recommend using useRef() or createRef() instead. ' +
1319
- 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
1320
- ' in Foo (at **)',
1321
- ]
1322
- : [],
1323
- );
1311
+ }).toErrorDev([
1312
+ 'Warning: Component "Foo" contains the string ref "bar". ' +
1313
+ 'Support for string refs will be removed in a future major release. ' +
1314
+ 'We recommend using useRef() or createRef() instead. ' +
1315
+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
1316
+ ' in Foo (at **)',
1317
+ ]);
1318
expect(fooInstance.refs.bar.test).toEqual('test');
1319
});
1320
});
packages/react-server/src/ReactFizzServer.js
+1
-5
@@ -129,7 +129,6 @@ import ReactSharedInternals from 'shared/ReactSharedInternals';
129
import {
130
disableLegacyContext,
131
disableModulePatternComponents,
132
- warnAboutDefaultPropsOnFunctionComponents,
132
enableScopeAPI,
133
enableSuspenseAvoidThisFallbackFizz,
134
enableFloat,
@@ -949,10 +948,7 @@ function validateFunctionComponentInDev(Component: any): void {
948
}
949
}
950
952
- if (
953
- warnAboutDefaultPropsOnFunctionComponents &&
954
- Component.defaultProps !== undefined
955
- ) {
951
+ if (Component.defaultProps !== undefined) {
952
const componentName = getComponentNameFromType(Component) || 'Unknown';
953
954
if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
packages/react/src/__tests__/ReactCoffeeScriptClass-test.coffee
+7
-13
@@ -9,7 +9,6 @@ PropTypes = null
9
React = null
10
ReactDOM = null
11
ReactDOMClient = null
12
-ReactFeatureFlags = null
12
act = null
13
14
describe 'ReactCoffeeScriptClass', ->
@@ -23,7 +22,6 @@ describe 'ReactCoffeeScriptClass', ->
22
React = require 'react'
23
ReactDOM = require 'react-dom'
24
ReactDOMClient = require 'react-dom/client'
26
- ReactFeatureFlags = require 'shared/ReactFeatureFlags'
25
act = require('jest-react').act
26
PropTypes = require 'prop-types'
27
container = document.createElement 'div'
@@ -545,17 +543,13 @@ describe 'ReactCoffeeScriptClass', ->
543
ref = React.createRef()
544
expect(->
545
test(React.createElement(Foo, ref: ref), 'DIV', 'foo')
548
- ).toErrorDev(
549
- if ReactFeatureFlags.warnAboutStringRefs
550
- then [
551
- 'Warning: Component "Foo" contains the string ref "inner". ' +
552
- 'Support for string refs will be removed in a future major release. ' +
553
- 'We recommend using useRef() or createRef() instead. ' +
554
- 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
555
- ' in Foo (at **)'
556
- ]
557
- else []
558
- );
546
+ ).toErrorDev([
547
+ 'Warning: Component "Foo" contains the string ref "inner". ' +
548
+ 'Support for string refs will be removed in a future major release. ' +
549
+ 'We recommend using useRef() or createRef() instead. ' +
550
+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
551
+ ' in Foo (at **)'
552
+ ]);
553
expect(ref.current.refs.inner.getName()).toBe 'foo'
554
555
it 'supports drilling through to the DOM using findDOMNode', ->
packages/react/src/__tests__/ReactES6Class-test.js
+7
-13
@@ -13,7 +13,6 @@ let PropTypes;
13
let React;
14
let ReactDOM;
15
let ReactDOMClient;
16
-let ReactFeatureFlags;
16
let act;
17
18
describe('ReactES6Class', () => {
@@ -32,7 +31,6 @@ describe('ReactES6Class', () => {
31
React = require('react');
32
ReactDOM = require('react-dom');
33
ReactDOMClient = require('react-dom/client');
35
- ReactFeatureFlags = require('shared/ReactFeatureFlags');
34
act = require('jest-react').act;
35
container = document.createElement('div');
36
root = ReactDOMClient.createRoot(container);
@@ -587,17 +585,13 @@ describe('ReactES6Class', () => {
585
const ref = React.createRef();
586
expect(() => {
587
test(<Foo ref={ref} />, 'DIV', 'foo');
590
- }).toErrorDev(
591
- ReactFeatureFlags.warnAboutStringRefs
592
- ? [
593
- 'Warning: Component "Foo" contains the string ref "inner". ' +
594
- 'Support for string refs will be removed in a future major release. ' +
595
- 'We recommend using useRef() or createRef() instead. ' +
596
- 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
597
- ' in Foo (at **)',
598
- ]
599
- : [],
600
- );
588
+ }).toErrorDev([
589
+ 'Warning: Component "Foo" contains the string ref "inner". ' +
590
+ 'Support for string refs will be removed in a future major release. ' +
591
+ 'We recommend using useRef() or createRef() instead. ' +
592
+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
593
+ ' in Foo (at **)',
594
+ ]);
595
expect(ref.current.refs.inner.getName()).toBe('foo');
596
});
597
packages/react/src/__tests__/ReactStrictMode-test.js
+11
-26
@@ -926,18 +926,11 @@ describe('string refs', () => {
926
expect(() => {
927
ReactDOM.render(<OuterComponent />, container);
928
}).toErrorDev(
929
- ReactFeatureFlags.warnAboutStringRefs
930
- ? 'Warning: Component "StrictMode" contains the string ref "somestring". ' +
931
- 'Support for string refs will be removed in a future major release. ' +
932
- 'We recommend using useRef() or createRef() instead. ' +
933
- 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
934
- ' in OuterComponent (at **)'
935
- : 'Warning: A string ref, "somestring", has been found within a strict mode tree. ' +
936
- 'String refs are a source of potential bugs and should be avoided. ' +
937
- 'We recommend using useRef() or createRef() instead. ' +
938
- 'Learn more about using refs safely here: ' +
939
- 'https://reactjs.org/link/strict-mode-string-ref\n' +
940
- ' in OuterComponent (at **)',
929
+ 'Warning: Component "StrictMode" contains the string ref "somestring". ' +
930
+ 'Support for string refs will be removed in a future major release. ' +
931
+ 'We recommend using useRef() or createRef() instead. ' +
932
+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
933
+ ' in OuterComponent (at **)',
934
);
935
936
// Dedup
@@ -973,20 +966,12 @@ describe('string refs', () => {
966
expect(() => {
967
ReactDOM.render(<OuterComponent />, container);
968
}).toErrorDev(
976
- ReactFeatureFlags.warnAboutStringRefs
977
- ? 'Warning: Component "InnerComponent" contains the string ref "somestring". ' +
978
- 'Support for string refs will be removed in a future major release. ' +
979
- 'We recommend using useRef() or createRef() instead. ' +
980
- 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
981
- ' in InnerComponent (at **)\n' +
982
- ' in OuterComponent (at **)'
983
- : 'Warning: A string ref, "somestring", has been found within a strict mode tree. ' +
984
- 'String refs are a source of potential bugs and should be avoided. ' +
985
- 'We recommend using useRef() or createRef() instead. ' +
986
- 'Learn more about using refs safely here: ' +
987
- 'https://reactjs.org/link/strict-mode-string-ref\n' +
988
- ' in InnerComponent (at **)\n' +
989
- ' in OuterComponent (at **)',
969
+ 'Warning: Component "InnerComponent" contains the string ref "somestring". ' +
970
+ 'Support for string refs will be removed in a future major release. ' +
971
+ 'We recommend using useRef() or createRef() instead. ' +
972
+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
973
+ ' in InnerComponent (at **)\n' +
974
+ ' in OuterComponent (at **)',
975
);
976
977
// Dedup
packages/react/src/__tests__/ReactTypeScriptClass-test.ts
+7
-12
@@ -17,7 +17,6 @@ import ReactDOMClient = require('react-dom/client');
17
import ReactDOMTestUtils = require('react-dom/test-utils');
18
import PropTypes = require('prop-types');
19
import internalAct = require('jest-react');
20
-import ReactFeatureFlags = require('shared/ReactFeatureFlags')
20
21
// Before Each
22
@@ -691,17 +690,13 @@ describe('ReactTypeScriptClass', function() {
690
const ref = React.createRef();
691
expect(() => {
692
test(React.createElement(ClassicRefs, {ref: ref}), 'DIV', 'foo');
694
- }).toErrorDev(
695
- ReactFeatureFlags.warnAboutStringRefs
696
- ? [
697
- 'Warning: Component "ClassicRefs" contains the string ref "inner". ' +
698
- 'Support for string refs will be removed in a future major release. ' +
699
- 'We recommend using useRef() or createRef() instead. ' +
700
- 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
701
- ' in ClassicRefs (at **)',
702
- ]
703
- : [],
704
- );
693
+ }).toErrorDev([
694
+ 'Warning: Component "ClassicRefs" contains the string ref "inner". ' +
695
+ 'Support for string refs will be removed in a future major release. ' +
696
+ 'We recommend using useRef() or createRef() instead. ' +
697
+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
698
+ ' in ClassicRefs (at **)',
699
+ ]);
700
expect(ref.current.refs.inner.getName()).toBe('foo');
701
});
702
packages/shared/ReactFeatureFlags.js
-7
@@ -207,17 +207,10 @@ export const disableTextareaChildren = false;
207
208
// New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
209
210
-// Part of the simplification of React.createElement so we can eventually move
211
-// from React.createElement to React.jsx
212
-// https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
213
-export const warnAboutDefaultPropsOnFunctionComponents = true; // deprecate later, not 18.0
214
-
210
// Enables a warning when trying to spread a 'key' to an element;
211
// a deprecated pattern we want to get rid of in the future
212
export const warnAboutSpreadingKeyToJSX = true;
213
219
-export const warnAboutStringRefs = true;
220
-
214
// -----------------------------------------------------------------------------
215
// Debugging and DevTools
216
// -----------------------------------------------------------------------------
packages/shared/forks/ReactFeatureFlags.native-fb.js
-2
@@ -40,8 +40,6 @@ export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
40
export const enableScopeAPI = false;
41
export const enableCreateEventHandleAPI = false;
42
export const enableSuspenseCallback = false;
43
-export const warnAboutDefaultPropsOnFunctionComponents = true;
44
-export const warnAboutStringRefs = true;
43
export const disableLegacyContext = false;
44
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
45
export const enableTrustedTypesIntegration = false;
packages/shared/forks/ReactFeatureFlags.native-oss.js
-2
@@ -30,8 +30,6 @@ export const enableSchedulerDebugging = false;
30
export const enableScopeAPI = false;
31
export const enableCreateEventHandleAPI = false;
32
export const enableSuspenseCallback = false;
33
-export const warnAboutDefaultPropsOnFunctionComponents = true;
34
-export const warnAboutStringRefs = true;
33
export const disableLegacyContext = false;
34
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
35
export const enableTrustedTypesIntegration = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.js
-2
@@ -30,8 +30,6 @@ export const enableSchedulerDebugging = false;
30
export const enableScopeAPI = false;
31
export const enableCreateEventHandleAPI = false;
32
export const enableSuspenseCallback = false;
33
-export const warnAboutDefaultPropsOnFunctionComponents = true;
34
-export const warnAboutStringRefs = true;
33
export const disableLegacyContext = false;
34
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
35
export const enableTrustedTypesIntegration = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.native.js
-2
@@ -30,8 +30,6 @@ export const enableSchedulerDebugging = false;
30
export const enableScopeAPI = false;
31
export const enableCreateEventHandleAPI = false;
32
export const enableSuspenseCallback = false;
33
-export const warnAboutDefaultPropsOnFunctionComponents = true;
34
-export const warnAboutStringRefs = true;
33
export const disableLegacyContext = false;
34
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
35
export const enableTrustedTypesIntegration = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
-2
@@ -30,8 +30,6 @@ export const disableInputAttributeSyncing = false;
30
export const enableScopeAPI = true;
31
export const enableCreateEventHandleAPI = false;
32
export const enableSuspenseCallback = true;
33
-export const warnAboutDefaultPropsOnFunctionComponents = true;
34
-export const warnAboutStringRefs = true;
33
export const disableLegacyContext = false;
34
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
35
export const enableTrustedTypesIntegration = false;
packages/shared/forks/ReactFeatureFlags.testing.js
-2
@@ -30,8 +30,6 @@ export const enableSchedulerDebugging = false;
30
export const enableScopeAPI = false;
31
export const enableCreateEventHandleAPI = false;
32
export const enableSuspenseCallback = false;
33
-export const warnAboutDefaultPropsOnFunctionComponents = true;
34
-export const warnAboutStringRefs = true;
33
export const disableLegacyContext = false;
34
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
35
export const enableTrustedTypesIntegration = false;
packages/shared/forks/ReactFeatureFlags.testing.www.js
-2
@@ -30,8 +30,6 @@ export const enableSchedulerDebugging = false;
30
export const enableScopeAPI = true;
31
export const enableCreateEventHandleAPI = true;
32
export const enableSuspenseCallback = true;
33
-export const warnAboutDefaultPropsOnFunctionComponents = true;
34
-export const warnAboutStringRefs = true;
33
export const disableLegacyContext = __EXPERIMENTAL__;
34
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
35
export const enableTrustedTypesIntegration = false;
packages/shared/forks/ReactFeatureFlags.www.js
-2
@@ -66,8 +66,6 @@ export const enableSchedulingProfiler: boolean =
66
// At least this will let us stop shipping <Profiler> implementation to all users.
67
export const enableSchedulerDebugging = true;
68
export const disableLegacyContext = __EXPERIMENTAL__;
69
-export const warnAboutStringRefs = true;
70
-export const warnAboutDefaultPropsOnFunctionComponents = true;
69
export const enableGetInspectorDataForInstanceInProduction = false;
70
71
export const enableCache = true;