_Profiler_ – React
_Profiler_ – React
v19
<Profiler>
<Profiler> lets you measure rendering performance of a React
tree programmatically.
Reference
<Profiler>
onRender callback
Usage
Reference
<Profiler>
https://react.dev/reference/react/Profiler 1/6
20/02/2025, 09:02 <Profiler> – React
Props
Caveats
onRender callback
React will call your onRender callback with information about what was
rendered.
Parameters
id : The string id prop of the <Profiler> tree that has just committed.
This lets you identify which part of the tree was committed if you are
using multiple profilers.
phase : "mount" , "update" or "nested-update" . This lets you know
whether the tree has just been mounted for the first time or re-rendered
due to a change in props, state, or Hooks.
actualDuration : The number of milliseconds spent rendering the
<Profiler> and its descendants for the current update. This indicates
how well the subtree makes use of memoization (e.g. memo and useMemo ).
Ideally this value should decrease significantly after the initial mount as
https://react.dev/reference/react/Profiler 2/6
20/02/2025, 09:02 <Profiler> – React
many of the descendants will only need to re-render if their specific props
change.
baseDuration : The number of milliseconds estimating how much time it
would take to re-render the entire <Profiler> subtree without any
optimizations. It is calculated by summing up the most recent render
durations of each component in the tree. This value estimates a worst-
case cost of rendering (e.g. the initial mount or a tree with no
memoization). Compare actualDuration against it to see if memoization
is working.
startTime : A numeric timestamp for when React began rendering the
current update.
commitTime : A numeric timestamp for when React committed the current
update. This value is shared between all profilers in a commit, enabling
them to be grouped if desirable.
Usage
<App>
<Profiler id="Sidebar" onRender={onRender}>
<Sidebar />
</Profiler>
<PageContent />
</App>
https://react.dev/reference/react/Profiler 3/6
20/02/2025, 09:02 <Profiler> – React
Pitfall
Note
you’re looking for an interactive profiler, try the Profiler tab in React
Developer Tools. It exposes similar functionality as a browser
extension.
<App>
<Profiler id="Sidebar" onRender={onRender}>
<Sidebar />
</Profiler>
<Profiler id="Content" onRender={onRender}>
<Content />
</Profiler>
</App>
https://react.dev/reference/react/Profiler 4/6
20/02/2025, 09:02 <Profiler> – React
<App>
<Profiler id="Sidebar" onRender={onRender}>
<Sidebar />
</Profiler>
<Profiler id="Content" onRender={onRender}>
<Content>
<Profiler id="Editor" onRender={onRender}>
<Editor />
</Profiler>
<Preview />
</Content>
</Profiler>
</App>
PREVIOUS
<Fragment> (<>)
NEXT
<StrictMode>
uwu?
https://react.dev/reference/react/Profiler 5/6
20/02/2025, 09:02 <Profiler> – React
Describing the UI
Adding Interactivity
Managing State
Escape Hatches
Community More
Acknowledgements Terms
https://react.dev/reference/react/Profiler 6/6