prevent spamming warnings related to performance measurement code (#7299)

* prevent spamming warnings related to performance measurement code

* minor changes in names and such

* -

* -

(cherry picked from commit 1cc9a5dc71)
This commit is contained in:
Sassan Haradji
2016-07-19 15:16:12 +04:30
committed by Paul O’Shannessy
parent 7cdcb4f696
commit 2debcef8f6
+26 -18
View File
@@ -52,6 +52,8 @@ var currentTimerStartTime = null;
var currentTimerNestedFlushDuration = null;
var currentTimerType = null;
var lifeCycleTimerHasWarned = false;
function clearHistory() {
ReactComponentTreeDevtool.purgeUnmountedComponents();
ReactHostOperationHistoryDevtool.clearHistory();
@@ -109,15 +111,18 @@ function beginLifeCycleTimer(debugID, timerType) {
if (currentFlushNesting === 0) {
return;
}
warning(
!currentTimerType,
'There is an internal error in the React performance measurement code. ' +
'Did not expect %s timer to start while %s timer is still in ' +
'progress for %s instance.',
timerType,
currentTimerType || 'no',
(debugID === currentTimerDebugID) ? 'the same' : 'another'
);
if (currentTimerType && !lifeCycleTimerHasWarned) {
warning(
false,
'There is an internal error in the React performance measurement code. ' +
'Did not expect %s timer to start while %s timer is still in ' +
'progress for %s instance.',
timerType,
currentTimerType || 'no',
(debugID === currentTimerDebugID) ? 'the same' : 'another'
);
lifeCycleTimerHasWarned = true;
}
currentTimerStartTime = performanceNow();
currentTimerNestedFlushDuration = 0;
currentTimerDebugID = debugID;
@@ -128,15 +133,18 @@ function endLifeCycleTimer(debugID, timerType) {
if (currentFlushNesting === 0) {
return;
}
warning(
currentTimerType === timerType,
'There is an internal error in the React performance measurement code. ' +
'We did not expect %s timer to stop while %s timer is still in ' +
'progress for %s instance. Please report this as a bug in React.',
timerType,
currentTimerType || 'no',
(debugID === currentTimerDebugID) ? 'the same' : 'another'
);
if (currentTimerType !== timerType && !lifeCycleTimerHasWarned) {
warning(
false,
'There is an internal error in the React performance measurement code. ' +
'We did not expect %s timer to stop while %s timer is still in ' +
'progress for %s instance. Please report this as a bug in React.',
timerType,
currentTimerType || 'no',
(debugID === currentTimerDebugID) ? 'the same' : 'another'
);
lifeCycleTimerHasWarned = true;
}
if (isProfiling) {
currentFlushMeasurements.push({
timerType,