React Performance: 7 Pitfalls to Stop Now

memo, useMemo, useCallback, unnecessary re-renders, large bundles — the React mistakes that silently tank your app.

By Rais Helmy, IT consultant in Kuala Lumpur, Malaysia.

React Performance. 7 Pitfalls. Fix them now.

Your React app feels sluggish. Users notice. You added memo everywhere and it got worse. Here are the real culprits — and proper fixes.

pitfall 1 · unnecessary re-renders

Expectation: best practice

  • Wrap expensive child components in React.memo so they only re-render when props change.
  • Colocate state — lift state only as high as needed, not all the way to root.
  • Use React DevTools Profiler to identify what actually re-renders.

Reality: what most teams do

  • Adding memo everywhere without profiling — adds overhead with no benefit.
  • Huge global state (Context or Redux) triggering entire tree re-renders on small updates.
  • "The profiler is confusing" — shipping blind and wondering why it's slow.

Better approach (code)

// ✦ Expensive child — memoize it
const HeavyList = React.memo(({ items }) => (
  <ul>{items.map(i => <ListItem key={i.id} item={i}/>)}</ul>
));

// ✦ Colocated state — filter stays local
function ProductPage() {
  const [filter, setFilter] = useState('');
  return (
    <>
      <FilterInput value={filter} onChange={setFilter}/>
      <HeavyList items={useFilteredItems(filter)}/>
    </>
  );
}

Common mistake (code)

// ✗ Global context re-renders everything
const AppContext = createContext({});
function App() {
  const [user, setUser] = useState(null);
  const [cart, setCart] = useState([]);
  const [theme, setTheme] = useState('light');
  const [filter, setFilter] = useState('');
  return (
    <AppContext.Provider value={{user,cart,theme,filter}}>
      <Everything/> // ALL of it re-renders on filter change
    </AppContext.Provider>

pitfall 2 · usememo / usecallback abuse

Expectation: best practice

  • useMemo for expensive derivations (filtering 10k items, heavy math).
  • useCallback only when passing callbacks to memoized children.
  • Measure first — premature optimisation adds memory pressure and cognitive overhead.

Reality: what most teams do

  • useMemo on every value, even primitive string/number concatenation.
  • useCallback on every function regardless of whether the child is memoized.
  • Dependency arrays wrong — stale closures, infinite loops, or ignored lint warnings.

Example (code)

// ✗ Pointless memoization
const title = useMemo(() => `Hello ${name}`, [name]);
const handleClick = useCallback(() => setCount(c+1), [c]);
// 👆 String concat costs less than memo overhead
// 👆 useCallback pointless if Button isn't memo'd

// ✦ Justified memoization
const sorted = useMemo(
  () => [...items].sort(expensiveSort),
  [items]   // only re-sort when items change
);
const onSubmit = useCallback(
  () => submitOrder(cart),
  [cart]   // stable ref for memoized <Form />
);

Your JavaScript bundle is your first performance problem.

A 3 MB bundle parsed on a mid-range Android phone costs ~4 seconds before a single pixel renders. Tree shaking, lazy imports, and route-based code splitting are not optional luxuries.

Warning signs

lodash fully imported · moment.js in bundle · no lazy() on routes · single 1MB+ chunk · no bundle analyser run

Fixes

date-fns / dayjs · lodash-es · React.lazy + Suspense on routes · Webpack Bundle Analyser · import cost VS Code extension

→ Run: npx vite-bundle-visualizer (Vite) or npx webpack-bundle-analyzer (CRA) before every major release.

pitfall 4 · key prop mistakes

Expectation: best practice

  • Use stable, unique IDs from your data as list keys.
  • Keys must be stable across renders — never use array index for reorderable lists.
  • Keys help React skip DOM mutations — wrong keys destroy this benefit.

Reality: what most teams do

  • key={index} on all lists — causes incorrect DOM reuse, broken animations, lost input state.
  • key={Math.random()} — remounts every item on every render, UI flashes constantly.
  • Keys on wrong element — key must be on the outermost element returned from map().

Better approach (code)

// ✦ Stable ID keys
{todos.map(todo => (
  <TodoItem
    key={todo.id}   // stable, unique
    item={todo}
  />
))}

Common mistake (code)

// ✗ Index keys — breaks reordering
{todos.map((todo, index) => (
  <TodoItem
    key={index}   // wrong: shifts on delete/sort
    item={todo}
  />
))}

// ✗ Random keys — remounts everything
{todos.map(todo => (
  <TodoItem key={Math.random()} item={todo}/>
))}

useEffect is not a data transformation tool.

Triggering state updates from inside effects to derive new state causes double renders (state → effect → setState → re-render). Derive values directly in render instead.

Wrong pattern

useEffect watching [items] → setFilteredItems(items.filter(...)) → extra render cycle, race conditions with async

Correct pattern

const filtered = useMemo(() => items.filter(...), [items, query]) — computed inline, zero extra renders

→ Rule of thumb: if you find yourself doing setState inside useEffect for synchronous derived data, compute it during render instead.