GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Implemented Profiler onCommit() and onPostCommit() hooks (#17910) · react/react@024a764

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • react-reconciler/src
      • ReactFiber.js
      • ReactFiberBeginWork.js
      • ReactFiberCommitWork.js
      • ReactFiberWorkLoop.js
      • ReactProfilerTimer.js
    • react/src/__tests__
      • ReactProfiler-test.internal.js
    • shared
      • ReactFeatureFlags.js
      • forks
        • ReactFeatureFlags.native-fb.js
        • ReactFeatureFlags.native-oss.js
        • ReactFeatureFlags.persistent.js
        • ReactFeatureFlags.test-renderer.js
        • ReactFeatureFlags.test-renderer.www.js
        • ReactFeatureFlags.testing.js
        • ReactFeatureFlags.testing.www.js
        • ReactFeatureFlags.www.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/react-reconciler/src/ReactFiber.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiber.js
+9-7Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -826,13 +826,8 @@ function createFiberFromProfiler(
826826
key: null | string,
827827
): Fiber {
828828
if (__DEV__) {
829-
if (
830-
typeof pendingProps.id !== 'string' ||
831-
typeof pendingProps.onRender !== 'function'
832-
) {
833-
console.error(
834-
'Profiler must specify an "id" string and "onRender" function as props',
835-
);
829+
if (typeof pendingProps.id !== 'string') {
830+
console.error('Profiler must specify an "id" as a prop');
836831
}
837832
}
838833

@@ -842,6 +837,13 @@ function createFiberFromProfiler(
842837
fiber.type = REACT_PROFILER_TYPE;
843838
fiber.expirationTime = expirationTime;
844839

840+
if (enableProfilerTimer) {
841+
fiber.stateNode = {
842+
effectDuration: 0,
843+
passiveEffectDuration: 0,
844+
};
845+
}
846+
845847
return fiber;
846848
}
847849

Collapse file

‎packages/react-reconciler/src/ReactFiberBeginWork.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberBeginWork.js
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,12 @@ function updateProfiler(
580580
) {
581581
if (enableProfilerTimer) {
582582
workInProgress.effectTag |= Update;
583+
584+
// Reset effect durations for the next eventual effect phase.
585+
// These are reset during render to allow the DevTools commit hook a chance to read them,
586+
const stateNode = workInProgress.stateNode;
587+
stateNode.effectDuration = 0;
588+
stateNode.passiveEffectDuration = 0;
583589
}
584590
const nextProps = workInProgress.pendingProps;
585591
const nextChildren = nextProps.children;
@@ -2944,6 +2950,12 @@ function beginWork(
29442950
if (hasChildWork) {
29452951
workInProgress.effectTag |= Update;
29462952
}
2953+
2954+
// Reset effect durations for the next eventual effect phase.
2955+
// These are reset during render to allow the DevTools commit hook a chance to read them,
2956+
const stateNode = workInProgress.stateNode;
2957+
stateNode.effectDuration = 0;
2958+
stateNode.passiveEffectDuration = 0;
29472959
}
29482960
break;
29492961
case SuspenseComponent: {

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.