How do I find unnecessary React renders?
Last checked 31 Aug 2026
Short answer
Use React DevTools' Profiler and the 'Highlight updates' setting to see which components re-render too often, then fix unstable props, missing memoisation, or state stored too high in the tree.
Tools to use
React DevTools (browser extension) has two features built for this:
- Highlight updates when components render — flashes a border around any component that re-renders, so you can visually spot loops.
- Profiler tab — record an interaction and see a flame graph of which components rendered and why.
Common causes in Lovable projects
- Inline objects/functions as props, e.g.
onClick={() => doThing()}orstyle={{...}}created fresh every render, which breaksReact.memoon the child. - State lifted too high, so a single input keystroke re-renders a whole page instead of just the input.
- Context providers wrapping large trees where any value change re-renders every consumer, even ones that don't use the changed field.
- Derived values recalculated every render instead of wrapped in
useMemo.
A prompt that helps
Profile the [page name] component tree and tell me which components re-render on every keystroke in the search box, and why.
Fixes, roughly in order of impact
- Move fast-changing state (like a text input) into the smallest component that needs it.
- Wrap expensive child components in
React.memoonce their props are stable. - Use
useMemo/useCallbackfor values and functions passed as props, only where profiling shows it matters. - Split large contexts into smaller ones scoped to what actually changes together.
What usually goes wrong
Adding useMemo and React.memo everywhere "just in case" adds complexity without measurable benefit — profile first, then optimise the components that actually show up as hot in the flame graph. See /questions/why-is-my-dashboard-slow for a page-level version of this problem.
Was this answer helpful?
Related questions
- AnswerWhy is my database making so many requests?Usually a component is re-fetching data on every render, a page is running the same query multiple times, or you're fetching entire tables instead of what's actually needed — ask Lovable to audit data-fetching patterns.
- AnswerHow do I improve Core Web Vitals?Focus on the three metrics Google measures — LCP (loading), INP (interactivity), and CLS (visual stability) — and fix the specific one flagged as poor, usually starting with images for LCP.
- AnswerHow do I lazy-load images?Ask Lovable to add native lazy-loading to images below the fold while keeping the hero/first-visible image loading eagerly, so visitors aren't downloading offscreen images before they're needed.
- AnswerHow do I remove unused code?Ask Lovable to search for unused components, imports and dependencies, or run a tool like ts-prune/depcheck via the terminal, then remove what's confirmed unused and re-test.