MCPcopy
hub / github.com/facebook/react / commitProfiler

Function commitProfiler

packages/react-reconciler/src/ReactFiberCommitEffects.js:935–969  ·  view source on GitHub ↗
(
  finishedWork: Fiber,
  current: Fiber | null,
  commitStartTime: number,
  effectDuration: number,
)

Source from the content-addressed store, hash-verified

933}
934
935function commitProfiler(
936 finishedWork: Fiber,
937 current: Fiber | null,
938 commitStartTime: number,
939 effectDuration: number,
940) {
941 const {id, onCommit, onRender} = (finishedWork.memoizedProps: ProfilerProps);
942
943 let phase: ProfilerPhase = current === null ? 'mount' : 'update';
944 if (enableProfilerNestedUpdatePhase) {
945 if (isCurrentUpdateNested()) {
946 phase = 'nested-update';
947 }
948 }
949
950 if (typeof onRender === 'function') {
951 onRender(
952 id,
953 phase,
954 // $FlowFixMe: This should be always a number in profiling mode
955 finishedWork.actualDuration,
956 // $FlowFixMe: This should be always a number in profiling mode
957 finishedWork.treeBaseDuration,
958 // $FlowFixMe: This should be always a number in profiling mode
959 finishedWork.actualStartTime,
960 commitStartTime,
961 );
962 }
963
964 if (enableProfilerCommitHooks) {
965 if (typeof onCommit === 'function') {
966 onCommit(id, phase, effectDuration, commitStartTime);
967 }
968 }
969}
970
971export function commitProfilerUpdate(
972 finishedWork: Fiber,

Callers 1

commitProfilerUpdateFunction · 0.85

Calls 3

isCurrentUpdateNestedFunction · 0.90
onRenderFunction · 0.85
onCommitFunction · 0.85

Tested by

no test coverage detected