Profiler and React Performance Tracks
Performance work becomes more reliable when you can see what scheduled work, how long it rendered, what committed, what Effects cost, and how React work overlaps browser/network activity.
Three complementary profiling layersβ
They overlap, but they do not provide identical information.
<Profiler>β
import { Profiler } from 'react';
<Profiler id="SearchResults" onRender={onRender}>
<SearchResults />
</Profiler>
Typical callback:
function onRender(
id,
phase,
actualDuration,
baseDuration,
startTime,
commitTime,
) {
console.table({
id,
phase,
actualDuration,
baseDuration,
startTime,
commitTime,
});
}
Use IDs that map to product regions such as SearchResults, CheckoutSummary, or DashboardChart.
actualDuration vs baseDurationβ
Example:
actualDuration: 8 ms
baseDuration: 90 ms
suggests substantial work was skipped.
If both are tiny, more manual memoization is unlikely to matter.
Profiling adds overheadβ
Normal production builds disable profiling instrumentation by default. React provides a profiling build for production-like performance investigation.
Use profiling to locate and compare bottlenecks, then validate important improvements under realistic production conditions.
React DevTools Profilerβ
Useful questions include:
- Which components rendered in this commit?
- Which subtree took the most time?
- What triggered the update?
- Did Context fan out broadly?
- Did moving state shrink the update surface?
- Did a targeted optimization reduce cost?
A flamegraph is evidence, not a verdict. Rendering itself is normal.
React Performance Tracksβ
React 19.2 introduced React-specific tracks for supported browser Performance panels. They align React work with JavaScript tasks, network activity, event-loop work, layout, and paint.
Current React guidance: Performance Tracks are available in development and profiling builds. Server tracks are development-only; profiling builds have more limited component/server instrumentation unless enabled through supported tooling.
Scheduler prioritiesβ
This makes the concurrency mental model observable rather than theoretical.
Render phases on the timelineβ
A slow interaction can therefore be decomposed by phase instead of blamed generically on βReact.β
Cascading updatesβ
Development traces can help identify which component scheduled the extra update.
Components trackβ
The Components track visualizes component durations and Effect durations as flamegraphs.
Events may include Mount, Unmount, Reconnect, and Disconnect. Reconnect/Disconnect are particularly useful with <Activity>, where hidden UI can preserve state while Effects disconnect and reconnect.
Changed propsβ
Development traces can show potential changed props for a component render.
That is evidence for a targeted identity/API fixβnot proof that every callback needs useCallback.
Profile Effects independentlyβ
A component can render in 2 ms and run an 80 ms Effect.
Common causes include synchronous third-party work, duplicated subscriptions, state-update loops, serialization/parsing, and layout reads/writes.
Server tracks and waterfallsβ
Development Server Performance Tracks can expose Promises feeding Server Components and async component durations.
If the work is independent, start it concurrently instead of accepting the serial critical path.
Development vs profiling buildsβ
React documents using react-dom/profiling through a bundler alias for profiling builds. Your framework may expose a supported mode.
Meaningful Profiler boundariesβ
Do not permanently wrap every tiny component.
Good boundaries map to product subsystems:
Dashboard
ChartPanel
ActivityFeed
SearchResults
CheckoutSummary
That makes measurements understandable and avoids drowning in instrumentation noise.
Compare before and afterβ
Run multiple samples and control dataset, device, browser, network, cache state, and interaction sequence.
Production observabilityβ
Common mistakesβ
- Profiling only the entire app without meaningful subsystem boundaries.
- Profiling tiny demos that do not resemble production data/composition.
- Treating every render as wasted.
- Ignoring Effect duration.
- Ignoring browser layout/paint.
- Leaving profiling instrumentation enabled in normal production unintentionally.
- Drawing conclusions from one noisy trace.
Interview questionsβ
<Profiler> vs Performance Tracks?β
<Profiler> gives programmatic subtree measurements. Performance Tracks place React scheduling/component/server events on the browser performance timeline alongside other platform work.
Why can profiling builds differ from normal production?β
Profiling instrumentation adds overhead and metadata that normal production removes.
What is a cascading update?β
An update scheduled during or immediately after existing React work that causes another render pass, often from Effect-driven derived state.
Why inspect changed props?β
Changed identity can explain why an expensive child rendered and whether a targeted memoization or API redesign would help.