- Open the Profiler
- A small reproduction
- Record and interpret a commit
- Use the Components Inspector as a follow-up
- Trace a rerender
- Common rerender sources
- Optimize only after evidence
- A practical debugging checklist
React rerenders are normal. A component being rendered does not necessarily mean that the browser updated the DOM, and a DOM update does not necessarily indicate a React performance problem.
The useful question is: why did this component render, and did it do work that I did not need it to do?
The React Developer Tools Profiler can help measure that cost. It records React commits, component render durations, and update-causing interactions. The Components tab can then help inspect the props, state, hooks, or context behind a suspicious component.
Open the Profiler
- Install React Developer Tools for your browser.
- Run the application in development mode.
- Open browser DevTools.
- Select the Profiler tab.
- Click the record button.
- Perform the interaction you want to investigate.
- Stop recording.
The Profiler view should display a timeline of commits. Select a commit to inspect render durations and which components participated. React Developer Tools may offer a flamegraph, a ranked view, a component detail view, or a “why did this render?” style explanation, depending on the installed version.
A small reproduction
Use this small example to compare local state, parent state, and context updates:
1 | import { createContext, memo, useContext, useState } from "react"; |
The example has two useful characteristics:
- the count button rerenders
App; - the theme button changes a context value.
Before changing the code, start a Profiler recording and click one button at a time. Do not click both buttons in one recording unless you explicitly want to compare the combined update.
The count interaction should create a commit containing App and perhaps the child components. The theme interaction should create another commit containing App and the context consumer. Compare the two recordings in separate or repeated sessions.
Do not use development console.log calls as the only test. React Strict Mode can run extra development-only render checks, so repeated log lines in development do not necessarily mean repeated user-visible work in production.
Record and interpret a commit
First separate committing the DOM from rendering React components:
- a commit is an update that React has finished applying to the screen;
- a component render is the React work done before that commit;
- a component’s timing shows how long its render took within the selected commit.
For each commit, inspect:
| View | What to look for |
|---|---|
| Timeline | When a commit happened and how long it took |
| Flamegraph | The component hierarchy and relative durations in one commit |
| Ranked chart | Components ordered by duration |
| Why did this render? | A development clue such as changed props or state |
The ranked chart is useful for finding a slow component, but the flamegraph is better for understanding which parent or child relationship caused it to appear. Select a slow component and compare it with the same interaction when memo, useMemo, or a state move is enabled or disabled.
React Developer Tools may show no useful performance difference for a fast interaction or a small example. That result is evidence that micro-optimizing it is probably not worthwhile.
Use the Components Inspector as a follow-up
After the Profiler identifies a suspicious component, switch to the Components tab and select that component. Inspect its props, state, hooks, context, source location, and whether its values changed.
For example, these values are generally considered new props:
1 | <Child options={{ mode: "compact" }} /> |
This is not a problem by itself. It becomes relevant when Child is memoized or when creating or rendering the props is expensive.
Trace a rerender
Start with a single interaction and a known starting state.
- Start a new recording.
- Perform the interaction exactly one time.
- Stop recording and select the resulting commit.
- Use the ranked chart or flamegraph to identify expensive or unexpected components.
- Switch to the Components tab and inspect a suspicious component’s props, state, hooks, and context.
- Look at the nearest parent or provider that owns a changed value.
- Trace the value back to its
setState, reducer, store subscription, or context provider. - Make only one hypothesis and change.
- Record the interaction again and compare commit time and component durations.
A state update on a child is usually the simplest case: select the child and confirm that a local state hook changed. A rerender of many descendants is more likely to start at an ancestor state update, a context update, or an external store subscription.
React Developer Tools may show the component that rendered, but it does not always prove which state setter or store subscription initiated the update. Use a breakpoint or a temporary targeted log to establish that last link.
Common rerender sources
Local state
A state update rerenders the component that owns that state. It also does not automatically rerender every descendant: React renders the parent and may still avoid work below it if the child element and props have not changed.
Parent rerenders
When a parent renders, React can schedule child renders as part of normal reconciliation. A child may render even if none of its props changed. The Profiler can show that relationship in a commit; the Components tab can confirm whether the child props stayed the same.
Context
A context consumer rerenders when the context value it observes changes. The provider in the example creates a new object on every App render:
1 | <ThemeContext.Provider value={{ theme }}> |
Changing theme is intentional because the consumer needs the new value. An unrelated count update also rerenders App, recreates the context object, and may unnecessarily rerender the context consumer unless its value is handled differently.
React compares the previous and next Context values using Object.is. When a Provider receives a new value that is not equal to the previous value, React schedules updates for components consuming that context.
For objects, Object.is compares references rather than their contents. Therefore, even if two objects contain identical properties, they are considered different if they are separate object instances.
1 | Object.is( |
Using useMemo to stabilize the Context value prevents unnecessary Context updates when its dependencies haven’t changed.
If a provider is frequently rerendered and all consumers need the same primitive or memoized value, move state up only when it makes sense for ownership, and memoize provider values that contain objects.
Inside App, add:
1 | const contextValue = useMemo(() => ({ theme }), [theme]); |
And replace:
1 | <ThemeContext.Provider value={{ theme }}> |
with:
1 | <ThemeContext.Provider value={contextValue}> |
Memoized components
memo is a separate optimization from React render behavior. A memoized component skips work when it receives props that pass shallow comparison.
In the example, ExpensiveChild and MemoizedChild receive the same string prop on count updates, but changing count also rerenders App. Depending on other factors, React may be able to bypass MemoizedChild while continuing to render ExpensiveChild.
memo does not freeze a component. A changed prop, changed context, a local state update, or an external store update can still cause rendering.
Strict Mode
In development, React Strict Mode can perform extra checks and development-only render passes to help detect unsafe effects and impure render logic. An update that appears twice in a development console may be normal when that behavior is enabled.
Use the Profiler recording and application behavior to investigate, then verify performance conclusions in the relevant production build or with a production-style performance measurement.
Optimize only after evidence
Once DevTools and a targeted log or breakpoint show a real source, consider the smallest fix that addresses it:
- move state closer to the component that owns the behavior;
- split a large context provider or separate frequently changing values;
- memoize a provider value or stable callback only where it removes real work;
- use
React.memofor an expensive child with stable props; - use
useMemofor a genuinely expensive calculation or stable object; - use
useCallbackto stabilize a callback that is passed to memoized children or used in dependency lists.
Avoid adding these primitives because a component happened to render once. Stable reference changes and memoization have their own cost and can make code harder to understand.
A practical debugging checklist
- Reproduce one update in a stable browser tab.
- Start a Profiler recording and perform the update once.
- Stop recording and select the commit.
- Compare the ranked chart and flamegraph for expensive or unexpected components.
- Switch to Components and inspect changed props, state, hooks, or context.
- Determine whether the component rerendered or remounted.
- Trace the changed value to its owner or subscription.
- Confirm whether React’s default behavior is sufficient.
- Change one dependency or boundary.
- Record the same interaction again and compare commits.
The Profiler is best for measuring how much time a commit or component render took and finding which components participated. The Components Inspector is useful for tracing which component values changed. Using both tools together gives a stronger before-and-after result than relying on rerender counts or screenshots alone.
Finally, remember that rerender count is not a bug report. Start with user-visible behavior and interaction cost, use the Components tab to narrow the cause, and optimize only after the evidence supports it.