-
-
+
);
}
@@ -1414,41 +1425,45 @@ describe('ResponderEventPlugin', () => {
const ancestors = [
// Common ancestor with self is self.
{
- one: parent.refs.P_P1_C1.refs.DIV_1,
- two: parent.refs.P_P1_C1.refs.DIV_1,
- com: parent.refs.P_P1_C1.refs.DIV_1,
+ one: parent.p_P1_C1Ref.current.div1Ref.current,
+ two: parent.p_P1_C1Ref.current.div1Ref.current,
+ com: parent.p_P1_C1Ref.current.div1Ref.current,
},
// Common ancestor with self is self - even if topmost DOM.
- {one: parent.refs.P, two: parent.refs.P, com: parent.refs.P},
+ {
+ one: parent.pRef.current,
+ two: parent.pRef.current,
+ com: parent.pRef.current,
+ },
// Siblings
{
- one: parent.refs.P_P1_C1.refs.DIV_1,
- two: parent.refs.P_P1_C1.refs.DIV_2,
- com: parent.refs.P_P1_C1.refs.DIV,
+ one: parent.p_P1_C1Ref.current.div1Ref.current,
+ two: parent.p_P1_C1Ref.current.div2Ref.current,
+ com: parent.p_P1_C1Ref.current.divRef.current,
},
// Common ancestor with parent is the parent.
{
- one: parent.refs.P_P1_C1.refs.DIV_1,
- two: parent.refs.P_P1_C1.refs.DIV,
- com: parent.refs.P_P1_C1.refs.DIV,
+ one: parent.p_P1_C1Ref.current.div1Ref.current,
+ two: parent.p_P1_C1Ref.current.divRef.current,
+ com: parent.p_P1_C1Ref.current.divRef.current,
},
// Common ancestor with grandparent is the grandparent.
{
- one: parent.refs.P_P1_C1.refs.DIV_1,
- two: parent.refs.P_P1,
- com: parent.refs.P_P1,
+ one: parent.p_P1_C1Ref.current.div1Ref.current,
+ two: parent.p_P1Ref.current,
+ com: parent.p_P1Ref.current,
},
// Grandparent across subcomponent boundaries.
{
- one: parent.refs.P_P1_C1.refs.DIV_1,
- two: parent.refs.P_P1_C2.refs.DIV_1,
- com: parent.refs.P_P1,
+ one: parent.p_P1_C1Ref.current.div1Ref.current,
+ two: parent.p_P1_C2Ref.current.div1Ref.current,
+ com: parent.p_P1Ref.current,
},
// Something deep with something one-off.
{
- one: parent.refs.P_P1_C1.refs.DIV_1,
- two: parent.refs.P_OneOff,
- com: parent.refs.P,
+ one: parent.p_P1_C1Ref.current.div1Ref.current,
+ two: parent.p_OneOffRef.current,
+ com: parent.pRef.current,
},
];
let i;
diff --git a/packages/react-reconciler/src/ReactChildFiber.new.js b/packages/react-reconciler/src/ReactChildFiber.new.js
index 6a984baec0c22..ea72a3de92047 100644
--- a/packages/react-reconciler/src/ReactChildFiber.new.js
+++ b/packages/react-reconciler/src/ReactChildFiber.new.js
@@ -97,6 +97,10 @@ if (__DEV__) {
};
}
+function isReactClass(type) {
+ return type.prototype && type.prototype.isReactComponent;
+}
+
function coerceRef(
returnFiber: Fiber,
current: Fiber | null,
@@ -120,7 +124,16 @@ function coerceRef(
element._owner &&
element._self &&
element._owner.stateNode !== element._self
- )
+ ) &&
+ // Will already throw with "Function components cannot have string refs"
+ !(
+ element._owner &&
+ ((element._owner: any): Fiber).tag !== ClassComponent
+ ) &&
+ // Will already warn with "Function components cannot be given refs"
+ !(typeof element.type === 'function' && !isReactClass(element.type)) &&
+ // Will already throw with "Element ref was specified as a string (someStringRef) but no owner was set"
+ element._owner
) {
const componentName =
getComponentNameFromFiber(returnFiber) || 'Component';
diff --git a/packages/react-reconciler/src/ReactChildFiber.old.js b/packages/react-reconciler/src/ReactChildFiber.old.js
index 8b6d4b8130dbd..9ced326c55960 100644
--- a/packages/react-reconciler/src/ReactChildFiber.old.js
+++ b/packages/react-reconciler/src/ReactChildFiber.old.js
@@ -97,6 +97,10 @@ if (__DEV__) {
};
}
+function isReactClass(type) {
+ return type.prototype && type.prototype.isReactComponent;
+}
+
function coerceRef(
returnFiber: Fiber,
current: Fiber | null,
@@ -120,7 +124,16 @@ function coerceRef(
element._owner &&
element._self &&
element._owner.stateNode !== element._self
- )
+ ) &&
+ // Will already throw with "Function components cannot have string refs"
+ !(
+ element._owner &&
+ ((element._owner: any): Fiber).tag !== ClassComponent
+ ) &&
+ // Will already warn with "Function components cannot be given refs"
+ !(typeof element.type === 'function' && !isReactClass(element.type)) &&
+ // Will already throw with "Element ref was specified as a string (someStringRef) but no owner was set"
+ element._owner
) {
const componentName =
getComponentNameFromFiber(returnFiber) || 'Component';
diff --git a/packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js b/packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js
index 635e426cd7f24..6bac75ab30f48 100644
--- a/packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js
+++ b/packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js
@@ -11,6 +11,7 @@
'use strict';
let React;
+let ReactFeatureFlags;
let ReactNoop;
let Scheduler;
@@ -19,6 +20,7 @@ describe('ReactIncrementalSideEffects', () => {
jest.resetModules();
React = require('react');
+ ReactFeatureFlags = require('shared/ReactFeatureFlags');
ReactNoop = require('react-noop-renderer');
Scheduler = require('scheduler');
});
@@ -1306,8 +1308,19 @@ describe('ReactIncrementalSideEffects', () => {
}
ReactNoop.render(
);
- expect(Scheduler).toFlushWithoutYielding();
-
+ 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 **)',
+ ]
+ : [],
+ );
expect(fooInstance.refs.bar.test).toEqual('test');
});
});
diff --git a/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.internal.js b/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.internal.js
index d5bc5e4454ef7..a2c458f6aafe1 100644
--- a/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.internal.js
+++ b/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.internal.js
@@ -271,13 +271,15 @@ describe('ReactTestRenderer', () => {
return
Hello, world
;
}
class Foo extends React.Component {
+ fooRef = React.createRef();
render() {
- return
;
+ return
;
}
}
class Baz extends React.Component {
+ bazRef = React.createRef();
render() {
- return
;
+ return
;
}
}
ReactTestRenderer.create(
);
@@ -298,11 +300,12 @@ describe('ReactTestRenderer', () => {
const mockAnchorInstance = {hover: () => {}};
const log = [];
class Foo extends React.Component {
+ barRef = React.createRef();
componentDidMount() {
- log.push(this.refs.bar);
+ log.push(this.barRef.current);
}
render() {
- return
Hello, world;
+ return
Hello, world;
}
}
function createNodeMock(element) {
@@ -355,7 +358,7 @@ describe('ReactTestRenderer', () => {
it('supports unmounting when using refs', () => {
class Foo extends React.Component {
render() {
- return
;
+ return
;
}
}
const inst = ReactTestRenderer.create(
, {
@@ -394,7 +397,11 @@ describe('ReactTestRenderer', () => {
};
class Foo extends React.Component {
render() {
- return this.props.useDiv ?
:
;
+ return this.props.useDiv ? (
+
+ ) : (
+
+ );
}
}
const inst = ReactTestRenderer.create(
, {
diff --git a/packages/react/src/__tests__/ReactCoffeeScriptClass-test.coffee b/packages/react/src/__tests__/ReactCoffeeScriptClass-test.coffee
index c6edb3c09ea91..c9dee4ac6c7fa 100644
--- a/packages/react/src/__tests__/ReactCoffeeScriptClass-test.coffee
+++ b/packages/react/src/__tests__/ReactCoffeeScriptClass-test.coffee
@@ -9,6 +9,7 @@ PropTypes = null
React = null
ReactDOM = null
ReactDOMClient = null
+ReactFeatureFlags = null
act = null
describe 'ReactCoffeeScriptClass', ->
@@ -22,6 +23,7 @@ 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'
@@ -528,7 +530,7 @@ describe 'ReactCoffeeScriptClass', ->
test React.createElement(Foo), 'DIV', 'bar-through-context'
- it 'supports classic refs', ->
+ it 'supports string refs', ->
class Foo extends React.Component
render: ->
React.createElement(InnerComponent,
@@ -537,7 +539,19 @@ describe 'ReactCoffeeScriptClass', ->
)
ref = React.createRef()
- test(React.createElement(Foo, ref: ref), 'DIV', 'foo')
+ 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 []
+ );
expect(ref.current.refs.inner.getName()).toBe 'foo'
it 'supports drilling through to the DOM using findDOMNode', ->
diff --git a/packages/react/src/__tests__/ReactContextValidator-test.js b/packages/react/src/__tests__/ReactContextValidator-test.js
index 2a21ba18df8ba..e4895d5c15bd4 100644
--- a/packages/react/src/__tests__/ReactContextValidator-test.js
+++ b/packages/react/src/__tests__/ReactContextValidator-test.js
@@ -46,6 +46,8 @@ describe('ReactContextValidator', () => {
};
class ComponentInFooBarContext extends React.Component {
+ childRef = React.createRef();
+
getChildContext() {
return {
foo: 'abc',
@@ -54,7 +56,7 @@ describe('ReactContextValidator', () => {
}
render() {
- return
;
+ return
;
}
}
ComponentInFooBarContext.childContextTypes = {
@@ -65,7 +67,7 @@ describe('ReactContextValidator', () => {
const instance = ReactTestUtils.renderIntoDocument(
,
);
- expect(instance.refs.child.context).toEqual({foo: 'abc'});
+ expect(instance.childRef.current.context).toEqual({foo: 'abc'});
});
it('should pass next context to lifecycles', () => {
diff --git a/packages/react/src/__tests__/ReactES6Class-test.js b/packages/react/src/__tests__/ReactES6Class-test.js
index f316db8896ff2..53a44f9fb17df 100644
--- a/packages/react/src/__tests__/ReactES6Class-test.js
+++ b/packages/react/src/__tests__/ReactES6Class-test.js
@@ -13,6 +13,7 @@ let PropTypes;
let React;
let ReactDOM;
let ReactDOMClient;
+let ReactFeatureFlags;
let act;
describe('ReactES6Class', () => {
@@ -31,6 +32,7 @@ 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);
@@ -568,14 +570,26 @@ describe('ReactES6Class', () => {
test(
, 'DIV', 'bar-through-context');
});
- it('supports classic refs', () => {
+ it('supports string refs', () => {
class Foo extends React.Component {
render() {
return
;
}
}
const ref = React.createRef();
- test(
, 'DIV', 'foo');
+ expect(() => {
+ test(
, '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 **)',
+ ]
+ : [],
+ );
expect(ref.current.refs.inner.getName()).toBe('foo');
});
diff --git a/packages/react/src/__tests__/ReactElement-test.js b/packages/react/src/__tests__/ReactElement-test.js
index 245ba507e1492..f1e9cffb8424d 100644
--- a/packages/react/src/__tests__/ReactElement-test.js
+++ b/packages/react/src/__tests__/ReactElement-test.js
@@ -93,7 +93,7 @@ describe('ReactElement', () => {
render() {
return (
-
+
);
}
diff --git a/packages/react/src/__tests__/ReactElementClone-test.js b/packages/react/src/__tests__/ReactElementClone-test.js
index 279ab84476add..1aecc91359c28 100644
--- a/packages/react/src/__tests__/ReactElementClone-test.js
+++ b/packages/react/src/__tests__/ReactElementClone-test.js
@@ -82,8 +82,10 @@ describe('ReactElementClone', () => {
it('should keep the original ref if it is not overridden', () => {
class Grandparent extends React.Component {
+ yoloRef = React.createRef();
+
render() {
- return
} />;
+ return
} />;
}
}
@@ -96,7 +98,7 @@ describe('ReactElementClone', () => {
}
const component = ReactTestUtils.renderIntoDocument(
);
- expect(component.refs.yolo.tagName).toBe('DIV');
+ expect(component.yoloRef.current.tagName).toBe('DIV');
});
it('should transfer the key property', () => {
@@ -174,21 +176,25 @@ describe('ReactElementClone', () => {
it('should support keys and refs', () => {
class Parent extends React.Component {
+ xyzRef = React.createRef();
+
render() {
const clone = React.cloneElement(this.props.children, {
key: 'xyz',
- ref: 'xyz',
+ ref: this.xyzRef,
});
expect(clone.key).toBe('xyz');
- expect(clone.ref).toBe('xyz');
+ expect(clone.ref).toBe(this.xyzRef);
return
{clone}
;
}
}
class Grandparent extends React.Component {
+ parentRef = React.createRef();
+
render() {
return (
-
+
);
@@ -196,30 +202,37 @@ describe('ReactElementClone', () => {
}
const component = ReactTestUtils.renderIntoDocument();
- expect(component.refs.parent.refs.xyz.tagName).toBe('SPAN');
+ expect(component.parentRef.current.xyzRef.current.tagName).toBe('SPAN');
});
it('should steal the ref if a new ref is specified', () => {
class Parent extends React.Component {
+ xyzRef = React.createRef();
+
render() {
- const clone = React.cloneElement(this.props.children, {ref: 'xyz'});
+ const clone = React.cloneElement(this.props.children, {
+ ref: this.xyzRef,
+ });
return {clone}
;
}
}
class Grandparent extends React.Component {
+ parentRef = React.createRef();
+ childRef = React.createRef();
+
render() {
return (
-
-
+
+
);
}
}
const component = ReactTestUtils.renderIntoDocument();
- expect(component.refs.child).toBeUndefined();
- expect(component.refs.parent.refs.xyz.tagName).toBe('SPAN');
+ expect(component.childRef).toEqual({current: null});
+ expect(component.parentRef.current.xyzRef.current.tagName).toBe('SPAN');
});
it('should overwrite props', () => {
diff --git a/packages/react/src/__tests__/ReactElementJSX-test.js b/packages/react/src/__tests__/ReactElementJSX-test.js
index 854618bf18ee1..ad42046087c4d 100644
--- a/packages/react/src/__tests__/ReactElementJSX-test.js
+++ b/packages/react/src/__tests__/ReactElementJSX-test.js
@@ -221,7 +221,7 @@ describe('ReactElement.jsx', () => {
class Parent extends React.Component {
render() {
return JSXRuntime.jsx('div', {
- children: JSXRuntime.jsx(Child, {ref: 'childElement'}),
+ children: JSXRuntime.jsx(Child, {ref: React.createRef()}),
});
}
}
diff --git a/packages/react/src/__tests__/ReactJSXElement-test.js b/packages/react/src/__tests__/ReactJSXElement-test.js
index 7a65555c344f0..7567e2b58fec5 100644
--- a/packages/react/src/__tests__/ReactJSXElement-test.js
+++ b/packages/react/src/__tests__/ReactJSXElement-test.js
@@ -78,10 +78,11 @@ describe('ReactJSXElement', () => {
});
it('extracts key and ref from the rest of the props', () => {
- const element = ;
+ const ref = React.createRef();
+ const element = ;
expect(element.type).toBe(Component);
expect(element.key).toBe('12');
- expect(element.ref).toBe('34');
+ expect(element.ref).toBe(ref);
const expectation = {foo: '56'};
Object.freeze(expectation);
expect(element.props).toEqual(expectation);
diff --git a/packages/react/src/__tests__/ReactStrictMode-test.js b/packages/react/src/__tests__/ReactStrictMode-test.js
index a266af4575243..b41497ae3ab72 100644
--- a/packages/react/src/__tests__/ReactStrictMode-test.js
+++ b/packages/react/src/__tests__/ReactStrictMode-test.js
@@ -926,12 +926,18 @@ describe('string refs', () => {
expect(() => {
ReactDOM.render(, container);
}).toErrorDev(
- '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 **)',
+ 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 **)',
);
// Dedup
@@ -967,13 +973,20 @@ describe('string refs', () => {
expect(() => {
ReactDOM.render(, container);
}).toErrorDev(
- '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 **)',
+ 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 **)',
);
// Dedup
diff --git a/packages/react/src/__tests__/ReactTypeScriptClass-test.ts b/packages/react/src/__tests__/ReactTypeScriptClass-test.ts
index ad621bbb40dd0..39304e9d6f2af 100644
--- a/packages/react/src/__tests__/ReactTypeScriptClass-test.ts
+++ b/packages/react/src/__tests__/ReactTypeScriptClass-test.ts
@@ -17,6 +17,7 @@ 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
@@ -686,9 +687,21 @@ describe('ReactTypeScriptClass', function() {
test(React.createElement(ProvideContext), 'DIV', 'bar-through-context');
});
- it('supports classic refs', function() {
+ it('supports string refs', function() {
const ref = React.createRef();
- test(React.createElement(ClassicRefs, {ref: ref}), 'DIV', 'foo');
+ 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 **)',
+ ]
+ : [],
+ );
expect(ref.current.refs.inner.getName()).toBe('foo');
});
diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js
index 9008562472e36..3a52dfd100a5c 100644
--- a/packages/shared/ReactFeatureFlags.js
+++ b/packages/shared/ReactFeatureFlags.js
@@ -219,7 +219,7 @@ export const warnAboutDefaultPropsOnFunctionComponents = false; // deprecate lat
// a deprecated pattern we want to get rid of in the future
export const warnAboutSpreadingKeyToJSX = true;
-export const warnAboutStringRefs = false;
+export const warnAboutStringRefs = true;
// -----------------------------------------------------------------------------
// Debugging and DevTools
diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fb.js
index 1777de0519625..f14d33de631d5 100644
--- a/packages/shared/forks/ReactFeatureFlags.native-fb.js
+++ b/packages/shared/forks/ReactFeatureFlags.native-fb.js
@@ -42,7 +42,7 @@ export const enableScopeAPI = false;
export const enableCreateEventHandleAPI = false;
export const enableSuspenseCallback = false;
export const warnAboutDefaultPropsOnFunctionComponents = false;
-export const warnAboutStringRefs = false;
+export const warnAboutStringRefs = true;
export const disableLegacyContext = false;
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
export const enableTrustedTypesIntegration = false;
diff --git a/packages/shared/forks/ReactFeatureFlags.native-oss.js b/packages/shared/forks/ReactFeatureFlags.native-oss.js
index 28052ac785658..296d4012ab2f9 100644
--- a/packages/shared/forks/ReactFeatureFlags.native-oss.js
+++ b/packages/shared/forks/ReactFeatureFlags.native-oss.js
@@ -32,7 +32,7 @@ export const enableScopeAPI = false;
export const enableCreateEventHandleAPI = false;
export const enableSuspenseCallback = false;
export const warnAboutDefaultPropsOnFunctionComponents = false;
-export const warnAboutStringRefs = false;
+export const warnAboutStringRefs = true;
export const disableLegacyContext = false;
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
export const enableTrustedTypesIntegration = false;
diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.js
index 88a6513c0b362..86f0d54eea169 100644
--- a/packages/shared/forks/ReactFeatureFlags.test-renderer.js
+++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.js
@@ -32,7 +32,7 @@ export const enableScopeAPI = false;
export const enableCreateEventHandleAPI = false;
export const enableSuspenseCallback = false;
export const warnAboutDefaultPropsOnFunctionComponents = false;
-export const warnAboutStringRefs = false;
+export const warnAboutStringRefs = true;
export const disableLegacyContext = false;
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
export const enableTrustedTypesIntegration = false;
diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js
index dcbd65ad715c3..f734afa27227d 100644
--- a/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js
+++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js
@@ -32,7 +32,7 @@ export const enableScopeAPI = false;
export const enableCreateEventHandleAPI = false;
export const enableSuspenseCallback = false;
export const warnAboutDefaultPropsOnFunctionComponents = false;
-export const warnAboutStringRefs = false;
+export const warnAboutStringRefs = true;
export const disableLegacyContext = false;
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
export const enableTrustedTypesIntegration = false;
diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
index e6e94b66ecf82..7ec00cbb2e9a9 100644
--- a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
+++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
@@ -32,7 +32,7 @@ export const enableScopeAPI = true;
export const enableCreateEventHandleAPI = false;
export const enableSuspenseCallback = true;
export const warnAboutDefaultPropsOnFunctionComponents = false;
-export const warnAboutStringRefs = false;
+export const warnAboutStringRefs = true;
export const disableLegacyContext = false;
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
export const enableTrustedTypesIntegration = false;
diff --git a/packages/shared/forks/ReactFeatureFlags.testing.js b/packages/shared/forks/ReactFeatureFlags.testing.js
index 97c1a0f443aca..efe5ef51e26ab 100644
--- a/packages/shared/forks/ReactFeatureFlags.testing.js
+++ b/packages/shared/forks/ReactFeatureFlags.testing.js
@@ -32,7 +32,7 @@ export const enableScopeAPI = false;
export const enableCreateEventHandleAPI = false;
export const enableSuspenseCallback = false;
export const warnAboutDefaultPropsOnFunctionComponents = false;
-export const warnAboutStringRefs = false;
+export const warnAboutStringRefs = true;
export const disableLegacyContext = false;
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
export const enableTrustedTypesIntegration = false;
diff --git a/packages/shared/forks/ReactFeatureFlags.testing.www.js b/packages/shared/forks/ReactFeatureFlags.testing.www.js
index e018c20d11f7a..f9e6b26567c31 100644
--- a/packages/shared/forks/ReactFeatureFlags.testing.www.js
+++ b/packages/shared/forks/ReactFeatureFlags.testing.www.js
@@ -32,7 +32,7 @@ export const enableScopeAPI = true;
export const enableCreateEventHandleAPI = true;
export const enableSuspenseCallback = true;
export const warnAboutDefaultPropsOnFunctionComponents = false;
-export const warnAboutStringRefs = false;
+export const warnAboutStringRefs = true;
export const disableLegacyContext = __EXPERIMENTAL__;
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
export const enableTrustedTypesIntegration = false;
diff --git a/packages/shared/forks/ReactFeatureFlags.www.js b/packages/shared/forks/ReactFeatureFlags.www.js
index 51ff1be193555..b0516f7f498b7 100644
--- a/packages/shared/forks/ReactFeatureFlags.www.js
+++ b/packages/shared/forks/ReactFeatureFlags.www.js
@@ -66,7 +66,7 @@ export const enableSchedulingProfiler: boolean =
export const enableSchedulerDebugging = true;
export const warnAboutDeprecatedLifecycles = true;
export const disableLegacyContext = __EXPERIMENTAL__;
-export const warnAboutStringRefs = false;
+export const warnAboutStringRefs = true;
export const warnAboutDefaultPropsOnFunctionComponents = false;
export const enableGetInspectorDataForInstanceInProduction = false;