File tree 1 file changed +11
-1
lines changed
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -65,19 +65,29 @@ export const generateUseBeacon =
65
65
66
66
traceManager . processSpan ( renderStartTaskEntry )
67
67
68
+ // React's concurrent rendering might pause and discard a render,
69
+ // which would mean that an effect scheduled for that render does not execute because the render itself was not committed to the DOM.
70
+ // we want to store the first time that the render was scheduled as the start time of rendering
71
+ const renderStartRef = useRef < Timestamp | undefined > ( )
72
+ if ( ! renderStartRef . current ) {
73
+ renderStartRef . current = renderStartTaskEntry . startTime
74
+ }
75
+
68
76
// Beacon effect for tracking 'component-render'. This will fire after every render as it does not have any dependencies:
69
77
useEffect ( ( ) => {
70
78
traceManager . processSpan (
71
79
makeEntry ( {
72
80
...config ,
81
+ startTime : renderStartRef . current ! ,
73
82
type : 'component-render' ,
74
- duration : performance . now ( ) - renderStartTaskEntry . startTime . now ,
83
+ duration : performance . now ( ) - renderStartRef . current ! . now ,
75
84
status,
76
85
attributes,
77
86
renderCount : renderCountRef . current ,
78
87
isIdle,
79
88
} ) ,
80
89
)
90
+ renderStartRef . current = undefined
81
91
} )
82
92
83
93
// Beacon effect for tracking 'component-unmount' entries
You can’t perform that action at this time.
0 commit comments