Key takeaway
- Optimise React performance by measuring first: use the Profiler, apply memo with stable props, split code with lazy, and let AI agents run the checks.
React performance optimisation is the practice of measuring which components render, how often and how expensively, and then removing unnecessary work or deferring code the user does not need yet. The order matters: measure first, change second, and keep only the changes the measurement supports.
This guide is for front-end engineers and technical leads whose React application feels slow as it grows. It covers how to measure with the profiler, the techniques that usually matter, how to avoid memoization that does nothing, and how AI agents can take over repetitive checks. For related reading see JavaScript and ReactJS unit testing, TDD and BDD, reactive programming and micro frontend integration.
How do you measure React performance?
The React Developer Tools page says the browser extension, available for Chrome, Firefox and Edge, adds a Components panel and a Profiler panel so you can inspect components, edit props and state, and identify performance problems. Record a profile, interact with the app as a user would, stop the recording, and read which components rendered and for how long.
For measurement from code, the Profiler reference describes the Profiler component, which lets you measure rendering performance of a React tree programmatically. You give it an id and an onRender callback. The callback receives actualDuration, the time spent rendering for the current update, and baseDuration, an estimate of re-rendering the whole subtree without optimisations. Comparing the two shows whether memoization is helping.
The same page says profiling adds overhead, so it is disabled in the production build by default, and that you must use a special profiling build to measure there. It also advises using the component sparingly because each use adds CPU and memory overhead.
Which techniques actually reduce rendering work?
| Technique | What it does | When it helps |
|---|---|---|
Skip re-renders with memo | Skips re-rendering a component when its props are unchanged | Component re-renders often with the same props and its render is expensive |
| Stable props | Keep objects and functions passed as props stable, using useMemo and useCallback or primitive values | Whenever you rely on memo |
Code splitting with lazy | Defers loading a component's code until it first renders | Large screens or features most users do not open at start |
| Fewer wrapper nodes | Use fragments instead of extra container elements | Deep trees with needless wrapper elements |
| Immutable updates | Create new arrays and objects instead of mutating state | Any state that drives memoized children |
When does memoization help, and when is it useless?
The memo reference says memo lets you skip re-rendering when props are unchanged, but that it is a performance optimisation, not a guarantee, and that if your code does not work without it you should fix the underlying problem first. It adds that memo is only valuable when a component re-renders often with the same props and its rendering is expensive, and that if there is no perceptible lag it is unnecessary.
The same page warns that memo is completely useless if the props passed are always different, for example an object or a plain function defined during rendering. This is the practical reason to avoid inline functions and fresh object literals in props of memoized children: the cost is not the allocation itself but the lost skip. The reference also notes that React Compiler applies the equivalent of memo automatically, so if you enable it you typically do not need to write memo by hand.
How does lazy loading improve load time?
The lazy reference explains that lazy defers loading a component's code until it is rendered for the first time, and that you wrap it in Suspense to show a fallback while it loads. It relies on dynamic import(), which may need support from your bundler or framework, and the lazy component must be the default export. Declare lazy components at the top level of a module, not inside another component, or state resets on re-render. Split along routes or heavy features first, since less code on the first load means the page becomes usable sooner.
How do AI agents change React performance work?
The repetitive parts are a good fit for agents: capturing a profile on each pull request, comparing render durations against a saved baseline, flagging new inline props on memoized components, and listing screens that load code they do not use. Engineers still decide which trade-off to accept. Such agents need scoped permissions and a record of what they ran. ElixirClaw is XenonStack's AI agents computing platform for building and operating agents like these. If you need hands-on help, see XenonStack's React.js application development services. Related: scalable data visualization with GraphQL and ReactJS.
What should you do first?
- Profile a real user journey and write down the three slowest renders.
- Confirm you are testing a production build, with profiling enabled if you need timings.
- Fix the cause for the slowest render before adding any memo.
- Split code for one heavy route with lazy and Suspense.
- Re-profile and keep only changes that show a gain.
To map one decision your agents make, and the data and policy it depends on, book a Context Workshop. See what happens in the workshop.
Frequently asked questions
How do I find slow components in React?
Record a profile with the Profiler panel in React Developer Tools while using the app, then read which components rendered and how long they took.
When should I use React.memo?
Use it when a component re-renders often with the same props and its rendering is expensive. The React documentation says that if there is no perceptible lag, memo is unnecessary.
Why does memo sometimes do nothing?
It compares props, so if you pass an object or function created during rendering, the props are always different and the component is never skipped.
Does React Compiler replace manual memoization?
The React documentation says React Compiler applies the equivalent of memo automatically, so with it enabled you typically do not need React.memo.
What does React lazy do?
It defers loading a component's code until it first renders. You wrap it in Suspense to show a fallback while the code loads.
Follow XenonStack on LinkedIn: XenonStack on LinkedIn for new guides on agentic AI, data and platform engineering.
Ready to put AI agents to work? Explore ElixirClaw, the agentic OS platform to build, orchestrate and govern AI agents.
Explore the XenonStack platform family: ElixirData · ElixirClaw · ElixirHub · NexaStack · MetaSecure · Neural AI · AgentGRC · AgentSRE · AgentAnalyst · AgentInstruct · AgentRAI · AgentScrum · AgentSearch · AgentForce · AI Aviator · SAIF Aviator · CohortIQ · XenonStack AI · XenonStack UAE