Skip to content

Commit

Permalink
Deduplication of warning messages in nested updates (#11081)
Browse files Browse the repository at this point in the history
  • Loading branch information
imanushree committed Oct 5, 2017
1 parent fa7461e commit f06d412
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/renderers/shared/fiber/ReactFiberReconciler.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ if (__DEV__) {
var ReactFiberInstrumentation = require('ReactFiberInstrumentation');
var ReactDebugCurrentFiber = require('ReactDebugCurrentFiber');
var getComponentName = require('getComponentName');
var didWarnAboutNestedUpdates = false;
}

var {
Expand Down Expand Up @@ -214,8 +215,10 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
if (__DEV__) {
if (
ReactDebugCurrentFiber.phase === 'render' &&
ReactDebugCurrentFiber.current !== null
ReactDebugCurrentFiber.current !== null &&
!didWarnAboutNestedUpdates
) {
didWarnAboutNestedUpdates = true;
warning(
false,
'Render methods should be a pure function of props and state; ' +
Expand Down
6 changes: 6 additions & 0 deletions src/renderers/shared/fiber/ReactFiberScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ if (__DEV__) {
stopCommitLifeCyclesTimer,
} = require('ReactDebugFiberPerf');

var didWarnAboutStateTransition = false;

var warnAboutUpdateOnUnmounted = function(
instance: React$ComponentType<any>,
) {
Expand All @@ -132,6 +134,10 @@ if (__DEV__) {
);
break;
case 'render':
if (didWarnAboutStateTransition) {
return;
}
didWarnAboutStateTransition = true;
warning(
false,
'Cannot update during an existing state transition (such as within ' +
Expand Down

0 comments on commit f06d412

Please sign in to comment.