Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deduplication of warning messages in nested updates (#11081) #11113

Merged
merged 1 commit into from
Oct 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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