mirror of
https://github.com/facebook/react.git
synced 2026-02-26 01:15:00 +00:00
Support for ReactFeatureFlags.logTopLevelRenders timing (#8687)
Call `console.time` / `console.timeEnd` for the top level component when `ReactFeatureFlags.logTopLevelRenders` is enabled
This commit is contained in:
@@ -61,8 +61,5 @@ src/renderers/shared/shared/__tests__/ReactEmptyComponent-test.js
|
||||
src/renderers/shared/shared/__tests__/ReactMultiChildText-test.js
|
||||
* should reorder keyed text nodes
|
||||
|
||||
src/renderers/shared/shared/__tests__/ReactUpdates-test.js
|
||||
* marks top-level updates
|
||||
|
||||
src/renderers/shared/shared/__tests__/refs-test.js
|
||||
* Should increase refs with an increase in divs
|
||||
|
||||
@@ -1598,6 +1598,7 @@ src/renderers/shared/shared/__tests__/ReactUpdates-test.js
|
||||
* should queue updates from during mount
|
||||
* calls componentWillReceiveProps setState callback properly
|
||||
* does not call render after a component as been deleted
|
||||
* marks top-level updates
|
||||
* throws in setState if the update callback is not a function
|
||||
* throws in replaceState if the update callback is not a function
|
||||
* throws in forceUpdate if the update callback is not a function
|
||||
|
||||
@@ -40,6 +40,7 @@ var ReactFiberCompleteWork = require('ReactFiberCompleteWork');
|
||||
var ReactFiberCommitWork = require('ReactFiberCommitWork');
|
||||
var ReactFiberHostContext = require('ReactFiberHostContext');
|
||||
var ReactCurrentOwner = require('ReactCurrentOwner');
|
||||
var ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
var getComponentName = require('getComponentName');
|
||||
|
||||
var { cloneFiber } = require('ReactFiber');
|
||||
@@ -628,6 +629,18 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(config : HostConfig<T, P,
|
||||
nextUnitOfWork = findNextUnitOfWork();
|
||||
}
|
||||
|
||||
let hostRootTimeMarker;
|
||||
if (
|
||||
ReactFeatureFlags.logTopLevelRenders &&
|
||||
nextUnitOfWork &&
|
||||
nextUnitOfWork.tag === HostRoot &&
|
||||
nextUnitOfWork.child
|
||||
) {
|
||||
const componentName = getComponentName(nextUnitOfWork.child) || '';
|
||||
hostRootTimeMarker = 'React update: ' + componentName;
|
||||
console.time(hostRootTimeMarker);
|
||||
}
|
||||
|
||||
// If there's a deadline, and we're not performing Task work, perform work
|
||||
// using this loop that checks the deadline on every iteration.
|
||||
if (deadline && priorityLevel > TaskPriority) {
|
||||
@@ -673,6 +686,10 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(config : HostConfig<T, P,
|
||||
}
|
||||
}
|
||||
|
||||
if (hostRootTimeMarker) {
|
||||
console.timeEnd(hostRootTimeMarker);
|
||||
}
|
||||
|
||||
return deadlineHasExpired;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user