[cleanup] remove feature flags warnAboutDefaultPropsOnFunctionComponents and warnAboutStringRefs (#25980)
These feature flags are fully rolled out and easy to clean up. Let's remove them!
This commit is contained in:
parent
7002a6743e
commit
0fce6bb498
|
@ -12,7 +12,6 @@
|
|||
let React;
|
||||
let ReactDOM;
|
||||
let ReactDOMServer;
|
||||
let ReactFeatureFlags;
|
||||
let ReactTestUtils;
|
||||
|
||||
describe('ReactComponent', () => {
|
||||
|
@ -22,7 +21,6 @@ describe('ReactComponent', () => {
|
|||
React = require('react');
|
||||
ReactDOM = require('react-dom');
|
||||
ReactDOMServer = require('react-dom/server');
|
||||
ReactFeatureFlags = require('shared/ReactFeatureFlags');
|
||||
ReactTestUtils = require('react-dom/test-utils');
|
||||
});
|
||||
|
||||
|
@ -137,24 +135,20 @@ describe('ReactComponent', () => {
|
|||
|
||||
expect(() => {
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
}).toErrorDev(
|
||||
ReactFeatureFlags.warnAboutStringRefs
|
||||
? [
|
||||
'Warning: Component "div" contains the string ref "inner". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in div (at **)\n' +
|
||||
' in Wrapper (at **)\n' +
|
||||
' in Component (at **)',
|
||||
'Warning: Component "Component" contains the string ref "outer". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in Component (at **)',
|
||||
]
|
||||
: [],
|
||||
);
|
||||
}).toErrorDev([
|
||||
'Warning: Component "div" contains the string ref "inner". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in div (at **)\n' +
|
||||
' in Wrapper (at **)\n' +
|
||||
' in Component (at **)',
|
||||
'Warning: Component "Component" contains the string ref "outer". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in Component (at **)',
|
||||
]);
|
||||
});
|
||||
|
||||
it('should not have string refs on unmounted components', () => {
|
||||
|
|
|
@ -14,7 +14,6 @@ const ReactDOMServerIntegrationUtils = require('./utils/ReactDOMServerIntegratio
|
|||
let React;
|
||||
let ReactDOM;
|
||||
let ReactDOMServer;
|
||||
let ReactFeatureFlags;
|
||||
let ReactTestUtils;
|
||||
|
||||
function initModules() {
|
||||
|
@ -23,7 +22,6 @@ function initModules() {
|
|||
React = require('react');
|
||||
ReactDOM = require('react-dom');
|
||||
ReactDOMServer = require('react-dom/server');
|
||||
ReactFeatureFlags = require('shared/ReactFeatureFlags');
|
||||
ReactTestUtils = require('react-dom/test-utils');
|
||||
|
||||
// Make them available to the helpers.
|
||||
|
@ -99,17 +97,13 @@ describe('ReactDOMServerIntegration', () => {
|
|||
root,
|
||||
true,
|
||||
);
|
||||
}).toErrorDev(
|
||||
ReactFeatureFlags.warnAboutStringRefs
|
||||
? [
|
||||
'Warning: Component "RefsComponent" contains the string ref "myDiv". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in RefsComponent (at **)',
|
||||
]
|
||||
: [],
|
||||
);
|
||||
}).toErrorDev([
|
||||
'Warning: Component "RefsComponent" contains the string ref "myDiv". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in RefsComponent (at **)',
|
||||
]);
|
||||
expect(component.refs.myDiv).toBe(root.firstChild);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -123,28 +123,24 @@ describe('reactiverefs', () => {
|
|||
let testRefsComponent;
|
||||
expect(() => {
|
||||
testRefsComponent = ReactDOM.render(<TestRefsComponent />, container);
|
||||
}).toErrorDev(
|
||||
ReactFeatureFlags.warnAboutStringRefs
|
||||
? [
|
||||
'Warning: Component "div" contains the string ref "resetDiv". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in div (at **)\n' +
|
||||
' in TestRefsComponent (at **)',
|
||||
'Warning: Component "span" contains the string ref "clickLog0". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in span (at **)\n' +
|
||||
' in ClickCounter (at **)\n' +
|
||||
' in div (at **)\n' +
|
||||
' in GeneralContainerComponent (at **)\n' +
|
||||
' in div (at **)\n' +
|
||||
' in TestRefsComponent (at **)',
|
||||
]
|
||||
: [],
|
||||
);
|
||||
}).toErrorDev([
|
||||
'Warning: Component "div" contains the string ref "resetDiv". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in div (at **)\n' +
|
||||
' in TestRefsComponent (at **)',
|
||||
'Warning: Component "span" contains the string ref "clickLog0". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in span (at **)\n' +
|
||||
' in ClickCounter (at **)\n' +
|
||||
' in div (at **)\n' +
|
||||
' in GeneralContainerComponent (at **)\n' +
|
||||
' in div (at **)\n' +
|
||||
' in TestRefsComponent (at **)',
|
||||
]);
|
||||
|
||||
expect(testRefsComponent instanceof TestRefsComponent).toBe(true);
|
||||
|
||||
|
@ -349,17 +345,13 @@ describe('ref swapping', () => {
|
|||
let a;
|
||||
expect(() => {
|
||||
a = ReactTestUtils.renderIntoDocument(<A />);
|
||||
}).toErrorDev(
|
||||
ReactFeatureFlags.warnAboutStringRefs
|
||||
? [
|
||||
'Warning: Component "A" contains the string ref "1". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in A (at **)',
|
||||
]
|
||||
: [],
|
||||
);
|
||||
}).toErrorDev([
|
||||
'Warning: Component "A" contains the string ref "1". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in A (at **)',
|
||||
]);
|
||||
expect(a.refs[1].nodeName).toBe('DIV');
|
||||
});
|
||||
|
||||
|
@ -546,18 +538,14 @@ describe('strings refs across renderers', () => {
|
|||
let inst;
|
||||
expect(() => {
|
||||
inst = ReactDOM.render(<Parent />, div1);
|
||||
}).toErrorDev(
|
||||
ReactFeatureFlags.warnAboutStringRefs
|
||||
? [
|
||||
'Warning: Component "Indirection" contains the string ref "child1". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in Indirection (at **)\n' +
|
||||
' in Parent (at **)',
|
||||
]
|
||||
: [],
|
||||
);
|
||||
}).toErrorDev([
|
||||
'Warning: Component "Indirection" contains the string ref "child1". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in Indirection (at **)\n' +
|
||||
' in Parent (at **)',
|
||||
]);
|
||||
|
||||
// Only the first ref has rendered yet.
|
||||
expect(inst.refs.child1.tagName).toBe('DIV');
|
||||
|
@ -567,14 +555,12 @@ describe('strings refs across renderers', () => {
|
|||
// Now both refs should be rendered.
|
||||
ReactDOM.render(<Parent />, div1);
|
||||
}).toErrorDev(
|
||||
ReactFeatureFlags.warnAboutStringRefs
|
||||
? [
|
||||
'Warning: Component "Root" contains the string ref "child2". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',
|
||||
]
|
||||
: [],
|
||||
[
|
||||
'Warning: Component "Root" contains the string ref "child2". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',
|
||||
],
|
||||
{withoutStack: true},
|
||||
);
|
||||
expect(inst.refs.child1.tagName).toBe('DIV');
|
||||
|
|
|
@ -28,7 +28,6 @@ import {
|
|||
} from 'shared/ReactSymbols';
|
||||
import {ClassComponent, HostText, HostPortal, Fragment} from './ReactWorkTags';
|
||||
import isArray from 'shared/isArray';
|
||||
import {warnAboutStringRefs} from 'shared/ReactFeatureFlags';
|
||||
import {checkPropStringCoercion} from 'shared/CheckStringCoercion';
|
||||
|
||||
import {
|
||||
|
@ -40,7 +39,6 @@ import {
|
|||
createFiberFromPortal,
|
||||
} from './ReactFiber';
|
||||
import {isCompatibleFamilyForHotReloading} from './ReactFiberHotReloading';
|
||||
import {StrictLegacyMode} from './ReactTypeOfMode';
|
||||
import {getIsHydrating} from './ReactFiberHydrationContext';
|
||||
import {pushTreeFork} from './ReactFiberTreeContext';
|
||||
|
||||
|
@ -113,10 +111,7 @@ function coerceRef(
|
|||
typeof mixedRef !== 'object'
|
||||
) {
|
||||
if (__DEV__) {
|
||||
// TODO: Clean this up once we turn on the string ref warning for
|
||||
// everyone, because the strict mode case will no longer be relevant
|
||||
if (
|
||||
(returnFiber.mode & StrictLegacyMode || warnAboutStringRefs) &&
|
||||
// We warn in ReactElement.js if owner and self are equal for string refs
|
||||
// because these cannot be automatically converted to an arrow function
|
||||
// using a codemod. Therefore, we don't have to warn about string refs again.
|
||||
|
@ -138,26 +133,15 @@ function coerceRef(
|
|||
const componentName =
|
||||
getComponentNameFromFiber(returnFiber) || 'Component';
|
||||
if (!didWarnAboutStringRefs[componentName]) {
|
||||
if (warnAboutStringRefs) {
|
||||
console.error(
|
||||
'Component "%s" contains the string ref "%s". Support for string refs ' +
|
||||
'will be removed in a future major release. We recommend using ' +
|
||||
'useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: ' +
|
||||
'https://reactjs.org/link/strict-mode-string-ref',
|
||||
componentName,
|
||||
mixedRef,
|
||||
);
|
||||
} else {
|
||||
console.error(
|
||||
'A string ref, "%s", has been found within a strict mode tree. ' +
|
||||
'String refs are a source of potential bugs and should be avoided. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: ' +
|
||||
'https://reactjs.org/link/strict-mode-string-ref',
|
||||
mixedRef,
|
||||
);
|
||||
}
|
||||
console.error(
|
||||
'Component "%s" contains the string ref "%s". Support for string refs ' +
|
||||
'will be removed in a future major release. We recommend using ' +
|
||||
'useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: ' +
|
||||
'https://reactjs.org/link/strict-mode-string-ref',
|
||||
componentName,
|
||||
mixedRef,
|
||||
);
|
||||
didWarnAboutStringRefs[componentName] = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,6 @@ import {
|
|||
disableModulePatternComponents,
|
||||
enableProfilerCommitHooks,
|
||||
enableProfilerTimer,
|
||||
warnAboutDefaultPropsOnFunctionComponents,
|
||||
enableScopeAPI,
|
||||
enableCache,
|
||||
enableLazyContextPropagation,
|
||||
|
@ -506,10 +505,7 @@ function updateMemoComponent(
|
|||
getComponentNameFromType(type),
|
||||
);
|
||||
}
|
||||
if (
|
||||
warnAboutDefaultPropsOnFunctionComponents &&
|
||||
Component.defaultProps !== undefined
|
||||
) {
|
||||
if (Component.defaultProps !== undefined) {
|
||||
const componentName = getComponentNameFromType(type) || 'Unknown';
|
||||
if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
|
||||
console.error(
|
||||
|
@ -2058,10 +2054,7 @@ function validateFunctionComponentInDev(workInProgress: Fiber, Component: any) {
|
|||
}
|
||||
}
|
||||
|
||||
if (
|
||||
warnAboutDefaultPropsOnFunctionComponents &&
|
||||
Component.defaultProps !== undefined
|
||||
) {
|
||||
if (Component.defaultProps !== undefined) {
|
||||
const componentName = getComponentNameFromType(Component) || 'Unknown';
|
||||
|
||||
if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
'use strict';
|
||||
|
||||
let React;
|
||||
let ReactFeatureFlags;
|
||||
let ReactNoop;
|
||||
let Scheduler;
|
||||
|
||||
|
@ -20,7 +19,6 @@ describe('ReactIncrementalSideEffects', () => {
|
|||
jest.resetModules();
|
||||
|
||||
React = require('react');
|
||||
ReactFeatureFlags = require('shared/ReactFeatureFlags');
|
||||
ReactNoop = require('react-noop-renderer');
|
||||
Scheduler = require('scheduler');
|
||||
});
|
||||
|
@ -1310,17 +1308,13 @@ describe('ReactIncrementalSideEffects', () => {
|
|||
ReactNoop.render(<Foo />);
|
||||
expect(() => {
|
||||
expect(Scheduler).toFlushWithoutYielding();
|
||||
}).toErrorDev(
|
||||
ReactFeatureFlags.warnAboutStringRefs
|
||||
? [
|
||||
'Warning: Component "Foo" contains the string ref "bar". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in Foo (at **)',
|
||||
]
|
||||
: [],
|
||||
);
|
||||
}).toErrorDev([
|
||||
'Warning: Component "Foo" contains the string ref "bar". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in Foo (at **)',
|
||||
]);
|
||||
expect(fooInstance.refs.bar.test).toEqual('test');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -129,7 +129,6 @@ import ReactSharedInternals from 'shared/ReactSharedInternals';
|
|||
import {
|
||||
disableLegacyContext,
|
||||
disableModulePatternComponents,
|
||||
warnAboutDefaultPropsOnFunctionComponents,
|
||||
enableScopeAPI,
|
||||
enableSuspenseAvoidThisFallbackFizz,
|
||||
enableFloat,
|
||||
|
@ -949,10 +948,7 @@ function validateFunctionComponentInDev(Component: any): void {
|
|||
}
|
||||
}
|
||||
|
||||
if (
|
||||
warnAboutDefaultPropsOnFunctionComponents &&
|
||||
Component.defaultProps !== undefined
|
||||
) {
|
||||
if (Component.defaultProps !== undefined) {
|
||||
const componentName = getComponentNameFromType(Component) || 'Unknown';
|
||||
|
||||
if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
|
||||
|
|
|
@ -9,7 +9,6 @@ PropTypes = null
|
|||
React = null
|
||||
ReactDOM = null
|
||||
ReactDOMClient = null
|
||||
ReactFeatureFlags = null
|
||||
act = null
|
||||
|
||||
describe 'ReactCoffeeScriptClass', ->
|
||||
|
@ -23,7 +22,6 @@ describe 'ReactCoffeeScriptClass', ->
|
|||
React = require 'react'
|
||||
ReactDOM = require 'react-dom'
|
||||
ReactDOMClient = require 'react-dom/client'
|
||||
ReactFeatureFlags = require 'shared/ReactFeatureFlags'
|
||||
act = require('jest-react').act
|
||||
PropTypes = require 'prop-types'
|
||||
container = document.createElement 'div'
|
||||
|
@ -545,17 +543,13 @@ describe 'ReactCoffeeScriptClass', ->
|
|||
ref = React.createRef()
|
||||
expect(->
|
||||
test(React.createElement(Foo, ref: ref), 'DIV', 'foo')
|
||||
).toErrorDev(
|
||||
if ReactFeatureFlags.warnAboutStringRefs
|
||||
then [
|
||||
'Warning: Component "Foo" contains the string ref "inner". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in Foo (at **)'
|
||||
]
|
||||
else []
|
||||
);
|
||||
).toErrorDev([
|
||||
'Warning: Component "Foo" contains the string ref "inner". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in Foo (at **)'
|
||||
]);
|
||||
expect(ref.current.refs.inner.getName()).toBe 'foo'
|
||||
|
||||
it 'supports drilling through to the DOM using findDOMNode', ->
|
||||
|
|
|
@ -13,7 +13,6 @@ let PropTypes;
|
|||
let React;
|
||||
let ReactDOM;
|
||||
let ReactDOMClient;
|
||||
let ReactFeatureFlags;
|
||||
let act;
|
||||
|
||||
describe('ReactES6Class', () => {
|
||||
|
@ -32,7 +31,6 @@ describe('ReactES6Class', () => {
|
|||
React = require('react');
|
||||
ReactDOM = require('react-dom');
|
||||
ReactDOMClient = require('react-dom/client');
|
||||
ReactFeatureFlags = require('shared/ReactFeatureFlags');
|
||||
act = require('jest-react').act;
|
||||
container = document.createElement('div');
|
||||
root = ReactDOMClient.createRoot(container);
|
||||
|
@ -587,17 +585,13 @@ describe('ReactES6Class', () => {
|
|||
const ref = React.createRef();
|
||||
expect(() => {
|
||||
test(<Foo ref={ref} />, 'DIV', 'foo');
|
||||
}).toErrorDev(
|
||||
ReactFeatureFlags.warnAboutStringRefs
|
||||
? [
|
||||
'Warning: Component "Foo" contains the string ref "inner". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in Foo (at **)',
|
||||
]
|
||||
: [],
|
||||
);
|
||||
}).toErrorDev([
|
||||
'Warning: Component "Foo" contains the string ref "inner". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in Foo (at **)',
|
||||
]);
|
||||
expect(ref.current.refs.inner.getName()).toBe('foo');
|
||||
});
|
||||
|
||||
|
|
|
@ -926,18 +926,11 @@ describe('string refs', () => {
|
|||
expect(() => {
|
||||
ReactDOM.render(<OuterComponent />, container);
|
||||
}).toErrorDev(
|
||||
ReactFeatureFlags.warnAboutStringRefs
|
||||
? 'Warning: Component "StrictMode" contains the string ref "somestring". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in OuterComponent (at **)'
|
||||
: 'Warning: A string ref, "somestring", has been found within a strict mode tree. ' +
|
||||
'String refs are a source of potential bugs and should be avoided. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: ' +
|
||||
'https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in OuterComponent (at **)',
|
||||
'Warning: Component "StrictMode" contains the string ref "somestring". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in OuterComponent (at **)',
|
||||
);
|
||||
|
||||
// Dedup
|
||||
|
@ -973,20 +966,12 @@ describe('string refs', () => {
|
|||
expect(() => {
|
||||
ReactDOM.render(<OuterComponent />, container);
|
||||
}).toErrorDev(
|
||||
ReactFeatureFlags.warnAboutStringRefs
|
||||
? 'Warning: Component "InnerComponent" contains the string ref "somestring". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in InnerComponent (at **)\n' +
|
||||
' in OuterComponent (at **)'
|
||||
: 'Warning: A string ref, "somestring", has been found within a strict mode tree. ' +
|
||||
'String refs are a source of potential bugs and should be avoided. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: ' +
|
||||
'https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in InnerComponent (at **)\n' +
|
||||
' in OuterComponent (at **)',
|
||||
'Warning: Component "InnerComponent" contains the string ref "somestring". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in InnerComponent (at **)\n' +
|
||||
' in OuterComponent (at **)',
|
||||
);
|
||||
|
||||
// Dedup
|
||||
|
|
|
@ -17,7 +17,6 @@ import ReactDOMClient = require('react-dom/client');
|
|||
import ReactDOMTestUtils = require('react-dom/test-utils');
|
||||
import PropTypes = require('prop-types');
|
||||
import internalAct = require('jest-react');
|
||||
import ReactFeatureFlags = require('shared/ReactFeatureFlags')
|
||||
|
||||
// Before Each
|
||||
|
||||
|
@ -691,17 +690,13 @@ describe('ReactTypeScriptClass', function() {
|
|||
const ref = React.createRef();
|
||||
expect(() => {
|
||||
test(React.createElement(ClassicRefs, {ref: ref}), 'DIV', 'foo');
|
||||
}).toErrorDev(
|
||||
ReactFeatureFlags.warnAboutStringRefs
|
||||
? [
|
||||
'Warning: Component "ClassicRefs" contains the string ref "inner". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in ClassicRefs (at **)',
|
||||
]
|
||||
: [],
|
||||
);
|
||||
}).toErrorDev([
|
||||
'Warning: Component "ClassicRefs" contains the string ref "inner". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'We recommend using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
|
||||
' in ClassicRefs (at **)',
|
||||
]);
|
||||
expect(ref.current.refs.inner.getName()).toBe('foo');
|
||||
});
|
||||
|
||||
|
|
|
@ -207,17 +207,10 @@ export const disableTextareaChildren = false;
|
|||
|
||||
// New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
|
||||
|
||||
// Part of the simplification of React.createElement so we can eventually move
|
||||
// from React.createElement to React.jsx
|
||||
// https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
|
||||
export const warnAboutDefaultPropsOnFunctionComponents = true; // deprecate later, not 18.0
|
||||
|
||||
// Enables a warning when trying to spread a 'key' to an element;
|
||||
// a deprecated pattern we want to get rid of in the future
|
||||
export const warnAboutSpreadingKeyToJSX = true;
|
||||
|
||||
export const warnAboutStringRefs = true;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Debugging and DevTools
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -40,8 +40,6 @@ export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
|
|||
export const enableScopeAPI = false;
|
||||
export const enableCreateEventHandleAPI = false;
|
||||
export const enableSuspenseCallback = false;
|
||||
export const warnAboutDefaultPropsOnFunctionComponents = true;
|
||||
export const warnAboutStringRefs = true;
|
||||
export const disableLegacyContext = false;
|
||||
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
|
||||
export const enableTrustedTypesIntegration = false;
|
||||
|
|
|
@ -30,8 +30,6 @@ export const enableSchedulerDebugging = false;
|
|||
export const enableScopeAPI = false;
|
||||
export const enableCreateEventHandleAPI = false;
|
||||
export const enableSuspenseCallback = false;
|
||||
export const warnAboutDefaultPropsOnFunctionComponents = true;
|
||||
export const warnAboutStringRefs = true;
|
||||
export const disableLegacyContext = false;
|
||||
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
|
||||
export const enableTrustedTypesIntegration = false;
|
||||
|
|
|
@ -30,8 +30,6 @@ export const enableSchedulerDebugging = false;
|
|||
export const enableScopeAPI = false;
|
||||
export const enableCreateEventHandleAPI = false;
|
||||
export const enableSuspenseCallback = false;
|
||||
export const warnAboutDefaultPropsOnFunctionComponents = true;
|
||||
export const warnAboutStringRefs = true;
|
||||
export const disableLegacyContext = false;
|
||||
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
|
||||
export const enableTrustedTypesIntegration = false;
|
||||
|
|
|
@ -30,8 +30,6 @@ export const enableSchedulerDebugging = false;
|
|||
export const enableScopeAPI = false;
|
||||
export const enableCreateEventHandleAPI = false;
|
||||
export const enableSuspenseCallback = false;
|
||||
export const warnAboutDefaultPropsOnFunctionComponents = true;
|
||||
export const warnAboutStringRefs = true;
|
||||
export const disableLegacyContext = false;
|
||||
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
|
||||
export const enableTrustedTypesIntegration = false;
|
||||
|
|
|
@ -30,8 +30,6 @@ export const disableInputAttributeSyncing = false;
|
|||
export const enableScopeAPI = true;
|
||||
export const enableCreateEventHandleAPI = false;
|
||||
export const enableSuspenseCallback = true;
|
||||
export const warnAboutDefaultPropsOnFunctionComponents = true;
|
||||
export const warnAboutStringRefs = true;
|
||||
export const disableLegacyContext = false;
|
||||
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
|
||||
export const enableTrustedTypesIntegration = false;
|
||||
|
|
|
@ -30,8 +30,6 @@ export const enableSchedulerDebugging = false;
|
|||
export const enableScopeAPI = false;
|
||||
export const enableCreateEventHandleAPI = false;
|
||||
export const enableSuspenseCallback = false;
|
||||
export const warnAboutDefaultPropsOnFunctionComponents = true;
|
||||
export const warnAboutStringRefs = true;
|
||||
export const disableLegacyContext = false;
|
||||
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
|
||||
export const enableTrustedTypesIntegration = false;
|
||||
|
|
|
@ -30,8 +30,6 @@ export const enableSchedulerDebugging = false;
|
|||
export const enableScopeAPI = true;
|
||||
export const enableCreateEventHandleAPI = true;
|
||||
export const enableSuspenseCallback = true;
|
||||
export const warnAboutDefaultPropsOnFunctionComponents = true;
|
||||
export const warnAboutStringRefs = true;
|
||||
export const disableLegacyContext = __EXPERIMENTAL__;
|
||||
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
|
||||
export const enableTrustedTypesIntegration = false;
|
||||
|
|
|
@ -66,8 +66,6 @@ export const enableSchedulingProfiler: boolean =
|
|||
// At least this will let us stop shipping <Profiler> implementation to all users.
|
||||
export const enableSchedulerDebugging = true;
|
||||
export const disableLegacyContext = __EXPERIMENTAL__;
|
||||
export const warnAboutStringRefs = true;
|
||||
export const warnAboutDefaultPropsOnFunctionComponents = true;
|
||||
export const enableGetInspectorDataForInstanceInProduction = false;
|
||||
|
||||
export const enableCache = true;
|
||||
|
|
Loading…
Reference in New Issue