diff --git a/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js b/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js
index 5c8488417d33a..965b04f30aaa9 100644
--- a/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js
+++ b/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js
@@ -215,11 +215,9 @@ describe('ReactComponentLifeCycle', () => {
ReactTestUtils.renderIntoDocument();
}).toWarnDev(
"Warning: Can't call setState on a component that is not yet mounted. " +
- 'This is a no-op, but it might indicate a bug in your application.\n\n' +
- 'To fix, assign the initial state in the StatefulComponent constructor. ' +
- 'If the state needs to reflect an external data source, ' +
- 'you may also add a componentDidMount lifecycle hook to StatefulComponent ' +
- 'and call setState there if the external data has changed.',
+ 'This is a no-op, but it might indicate a bug in your application. ' +
+ 'Instead, assign to `this.state` directly or define a `state = {};` ' +
+ 'class property with the desired state in the StatefulComponent component.',
);
// Check deduplication; (no extra warnings should be logged).
diff --git a/packages/react-dom/src/__tests__/ReactCompositeComponent-test.js b/packages/react-dom/src/__tests__/ReactCompositeComponent-test.js
index 4b8b996467914..216afa8550d3e 100644
--- a/packages/react-dom/src/__tests__/ReactCompositeComponent-test.js
+++ b/packages/react-dom/src/__tests__/ReactCompositeComponent-test.js
@@ -239,11 +239,9 @@ describe('ReactCompositeComponent', () => {
const container = document.createElement('div');
expect(() => ReactDOM.render(, container)).toWarnDev(
"Warning: Can't call forceUpdate on a component that is not yet mounted. " +
- 'This is a no-op, but it might indicate a bug in your application.\n\n' +
- 'To fix, assign the initial state in the MyComponent constructor. ' +
- 'If the state needs to reflect an external data source, ' +
- 'you may also add a componentDidMount lifecycle hook to MyComponent ' +
- 'and call setState there if the external data has changed.',
+ 'This is a no-op, but it might indicate a bug in your application. ' +
+ 'Instead, assign to `this.state` directly or define a `state = {};` ' +
+ 'class property with the desired state in the MyComponent component.',
);
// No additional warning should be recorded
@@ -265,11 +263,9 @@ describe('ReactCompositeComponent', () => {
const container = document.createElement('div');
expect(() => ReactDOM.render(, container)).toWarnDev(
"Warning: Can't call setState on a component that is not yet mounted. " +
- 'This is a no-op, but it might indicate a bug in your application.\n\n' +
- 'To fix, assign the initial state in the MyComponent constructor. ' +
- 'If the state needs to reflect an external data source, ' +
- 'you may also add a componentDidMount lifecycle hook to MyComponent ' +
- 'and call setState there if the external data has changed.',
+ 'This is a no-op, but it might indicate a bug in your application. ' +
+ 'Instead, assign to `this.state` directly or define a `state = {};` ' +
+ 'class property with the desired state in the MyComponent component.',
);
// No additional warning should be recorded
diff --git a/packages/react/src/ReactNoopUpdateQueue.js b/packages/react/src/ReactNoopUpdateQueue.js
index 3b18c5b8b9b9f..ffd47dacb483a 100644
--- a/packages/react/src/ReactNoopUpdateQueue.js
+++ b/packages/react/src/ReactNoopUpdateQueue.js
@@ -22,14 +22,11 @@ function warnNoop(publicInstance, callerName) {
warning(
false,
"Can't call %s on a component that is not yet mounted. " +
- 'This is a no-op, but it might indicate a bug in your application.\n\n' +
- 'To fix, assign the initial state in the %s constructor. ' +
- 'If the state needs to reflect an external data source, ' +
- 'you may also add a componentDidMount lifecycle hook to %s ' +
- 'and call setState there if the external data has changed.',
+ 'This is a no-op, but it might indicate a bug in your application. ' +
+ 'Instead, assign to `this.state` directly or define a `state = {};` ' +
+ 'class property with the desired state in the %s component.',
callerName,
componentName,
- componentName,
);
didWarnStateUpdateForUnmountedComponent[warningKey] = true;
}