@samitouri / QOS-React / commits / 1cc9a5dc71

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

* prevent spamming warnings related to performance measurement code * minor changes in names and such * - * -

Sassan Haradji committed Jul 19, 2016 at 15:16 UTC 1cc9a5dc718b7af8801a8ea00b00cf5043bc84d7
1 file changed +26 -18
src/renderers/shared/ReactDebugTool.js
+26 -18
@@ -52,6 +52,8 @@ var currentTimerStartTime = null;
52 var currentTimerNestedFlushDuration = null;
53 var currentTimerType = null;
54
55 +var lifeCycleTimerHasWarned = false;
56 +
57 function clearHistory() {
58 ReactComponentTreeDevtool.purgeUnmountedComponents();
59 ReactHostOperationHistoryDevtool.clearHistory();
@@ -109,15 +111,18 @@ function beginLifeCycleTimer(debugID, timerType) {
111 if (currentFlushNesting === 0) {
112 return;
113 }
112 - warning(
113 - !currentTimerType,
114 - 'There is an internal error in the React performance measurement code. ' +
115 - 'Did not expect %s timer to start while %s timer is still in ' +
116 - 'progress for %s instance.',
117 - timerType,
118 - currentTimerType || 'no',
119 - (debugID === currentTimerDebugID) ? 'the same' : 'another'
120 - );
114 + if (currentTimerType && !lifeCycleTimerHasWarned) {
115 + warning(
116 + false,
117 + 'There is an internal error in the React performance measurement code. ' +
118 + 'Did not expect %s timer to start while %s timer is still in ' +
119 + 'progress for %s instance.',
120 + timerType,
121 + currentTimerType || 'no',
122 + (debugID === currentTimerDebugID) ? 'the same' : 'another'
123 + );
124 + lifeCycleTimerHasWarned = true;
125 + }
126 currentTimerStartTime = performanceNow();
127 currentTimerNestedFlushDuration = 0;
128 currentTimerDebugID = debugID;
@@ -128,15 +133,18 @@ function endLifeCycleTimer(debugID, timerType) {
133 if (currentFlushNesting === 0) {
134 return;
135 }
131 - warning(
132 - currentTimerType === timerType,
133 - 'There is an internal error in the React performance measurement code. ' +
134 - 'We did not expect %s timer to stop while %s timer is still in ' +
135 - 'progress for %s instance. Please report this as a bug in React.',
136 - timerType,
137 - currentTimerType || 'no',
138 - (debugID === currentTimerDebugID) ? 'the same' : 'another'
139 - );
136 + if (currentTimerType !== timerType && !lifeCycleTimerHasWarned) {
137 + warning(
138 + false,
139 + 'There is an internal error in the React performance measurement code. ' +
140 + 'We did not expect %s timer to stop while %s timer is still in ' +
141 + 'progress for %s instance. Please report this as a bug in React.',
142 + timerType,
143 + currentTimerType || 'no',
144 + (debugID === currentTimerDebugID) ? 'the same' : 'another'
145 + );
146 + lifeCycleTimerHasWarned = true;
147 + }
148 if (isProfiling) {
149 currentFlushMeasurements.push({
150 timerType,