Skip to content

Commit e862966

Browse files
anushreesubramanigaearon
authored andcommitted
Deduplication of warning messages in nested updates (#11081) (#11113)
1 parent c75eed2 commit e862966

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/renderers/shared/fiber/ReactFiberReconciler.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ if (__DEV__) {
3434
var ReactFiberInstrumentation = require('ReactFiberInstrumentation');
3535
var ReactDebugCurrentFiber = require('ReactDebugCurrentFiber');
3636
var getComponentName = require('getComponentName');
37+
var didWarnAboutNestedUpdates = false;
3738
}
3839

3940
var {
@@ -214,8 +215,10 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
214215
if (__DEV__) {
215216
if (
216217
ReactDebugCurrentFiber.phase === 'render' &&
217-
ReactDebugCurrentFiber.current !== null
218+
ReactDebugCurrentFiber.current !== null &&
219+
!didWarnAboutNestedUpdates
218220
) {
221+
didWarnAboutNestedUpdates = true;
219222
warning(
220223
false,
221224
'Render methods should be a pure function of props and state; ' +

src/renderers/shared/fiber/ReactFiberScheduler.js

+6
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ if (__DEV__) {
109109
stopCommitLifeCyclesTimer,
110110
} = require('ReactDebugFiberPerf');
111111

112+
var didWarnAboutStateTransition = false;
113+
112114
var warnAboutUpdateOnUnmounted = function(
113115
instance: React$ComponentType<any>,
114116
) {
@@ -132,6 +134,10 @@ if (__DEV__) {
132134
);
133135
break;
134136
case 'render':
137+
if (didWarnAboutStateTransition) {
138+
return;
139+
}
140+
didWarnAboutStateTransition = true;
135141
warning(
136142
false,
137143
'Cannot update during an existing state transition (such as within ' +

0 commit comments

Comments
 (0)