@samitouri / QOS-React / commits / abe9a0ce94

Ignore lifecycle events outside batches

Technically this shouldn't happen but it seems possible with ReactNativeMount.unmountComponentAtNode(). For now, let's just ignore these lifecycle events because ReactPerf makes a hard assumption that all lifecycle hooks happen inside batches. We can revisit later when we have a comprehensive test suite for ReactPerf itself.

Dan Abramov committed Apr 29, 2016 at 21:14 UTC abe9a0ce94145d286c251ac66c7e17ea2ae879ad
1 file changed +2 -2
src/isomorphic/ReactDebugTool.js
+2 -2
@@ -144,7 +144,7 @@ var ReactDebugTool = {
144 onBeginLifeCycleTimer(debugID, timerType) {
145 emitEvent('onBeginLifeCycleTimer', debugID, timerType);
146 if (__DEV__) {
147 - if (isProfiling) {
147 + if (isProfiling && currentFlushNesting > 0) {
148 warning(
149 !currentTimerType,
150 'There is an internal error in the React performance measurement code. ' +
@@ -162,7 +162,7 @@ var ReactDebugTool = {
162 },
163 onEndLifeCycleTimer(debugID, timerType) {
164 if (__DEV__) {
165 - if (isProfiling) {
165 + if (isProfiling && currentFlushNesting > 0) {
166 warning(
167 currentTimerType === timerType,
168 'There is an internal error in the React performance measurement code. ' +