React Performance Optimization: 17 Renders to 3

🚀 My component rendered 17 times… for a single click. Do you know why? Was debugging a product listing page recently. Changed one filter… and React decided to re-render the list 17 times. UI wasn’t broken, but it felt slightly off. ~200–300ms delay on interaction. Not huge… but noticeable. Checked profiler → turns out a lot of unnecessary work. Main issues: • Parent state change → whole list re-render • Inline onClick → new function every time • Some data transformations running again and again • No memoization anywhere One example 👇 <ProductCard onClick={() => handleClick(id)} /> This looks harmless, but it creates a new function on every render. So React thinks props changed → re-render. ✅ Fixed it with useCallback. Another thing I noticed: Even though filtering was handled by API, we were still doing small stuff on frontend like: const enriched = products.map(...) Individually cheap… but with multiple re-renders, it adds up. ✅ Wrapped it in useMemo. ✅ Also wrapped list items with React.memo ✅ After fixes: • 17 renders → 3 • ~150ms → ~35ms UI feels much smoother now (especially on slower devices) Takeaway: Most of the time, performance issues are not “big problems” It’s small things… happening multiple times. If you haven’t checked your components in React Profiler yet, do it once. You might be surprised 😄 #reactjs #javascript #frontend #webperformance #optimization

To view or add a comment, sign in

Explore content categories