ReactError Fix2026 Updated

React Component Not Re-rendering— Fixed [Complete Guide 2026]

Also covers: state changes but UI does not update · mutation bug · stale closure

January 20266 min readReact 18 · Next.js

⚡ Most Common Fix — Never Mutate State

component.jsx
// ❌ WRONG — mutation, same reference, no re-render
const [user, setUser] = useState({ name: 'Alice' })
user.name = 'Bob'    // mutated in place
setUser(user)        // same object reference → React skips re-render

// ✅ CORRECT — new object reference → React detects change → re-renders
setUser(prev => ({ ...prev, name: 'Bob' }))

Why React Does Not Re-render

React uses reference equality to decide whether state changed. For primitives (string, number, boolean), it compares values. For objects and arrays, it compares references — the memory address. If the reference is the same, React assumes nothing changed and skips the render.

CauseWhy React skipsFix
Mutating object/array directlySame referenceSpread into new object/array
Setting same primitive valueValue unchangedDesign logic to produce new value
React.memo with stable propsNo prop change detectedPass updated prop or remove memo
Stale closureComponent reads old render valueFix deps / use functional update
Child not receiving updated propParent not passing new valuePass state as prop explicitly
1

State Mutation — Must Create New Reference

UI stuck after state update — most common cause
2 min
component.jsx
// ❌ WRONG — all of these mutate without creating new reference
const [items, setItems] = useState([1, 2, 3])
items.push(4)                   // mutation
items[0] = 99                   // mutation
setItems(items)                 // same reference → no re-render

const [user, setUser] = useState({ name: 'Alice', score: 0 })
user.score++                    // mutation
setUser(user)                   // same reference → no re-render

// ✅ CORRECT — always create new reference
setItems(prev => [...prev, 4])                           // add
setItems(prev => prev.filter(i => i !== 2))              // remove
setItems(prev => prev.map(i => i === 1 ? 99 : i))        // update

setUser(prev => ({ ...prev, score: prev.score + 1 }))    // update property
setUser(prev => ({ ...prev, address: { ...prev.address, city: 'NYC' } })) // nested
2

Same Primitive Value — No Re-render

setState called but value is unchanged
1 min
component.jsx
// This is correct behaviour — React is being efficient
const [count, setCount] = useState(5)
setCount(5)   // same value → React skips re-render, nothing to update

// ✅ If you need a re-render even with same value (rare), use object
const [, forceUpdate] = useReducer(x => x + 1, 0)
forceUpdate()  // always triggers re-render

// More commonly — rethink why you need a re-render with the same value
// Usually means state structure needs redesigning
3

React.memo Blocking Legitimate Re-render

Memoized component not updating
2 min
component.jsx
// React.memo does shallow comparison
// Object and function props are NEW references every parent render
// → memo sees "different" props → does re-render (usually desired)
// → But if props are SAME primitives → memo blocks → desired

// Debugging: remove memo temporarily
// If component updates without memo → memo is blocking correctly
// If component still doesn't update without memo → mutation bug

// ✅ When memo correctly blocks re-render with same props:
const MemoChild = memo(function Child({ name, count }) {
  return <div>{name}: {count}</div>
})

// ✅ Custom comparison if needed:
const MemoChild = memo(
  function Child({ data }) { return <div>{data.name}</div> },
  (prevProps, nextProps) => prevProps.data.id === nextProps.data.id
)
4

Stale Closure — Component Reads Old Value

State updated but component shows old value
2 min
component.jsx
// ❌ WRONG — interval captures count=0 and never sees updates
const [count, setCount] = useState(0)
useEffect(() => {
  const id = setInterval(() => {
    console.log(count)   // always 0 — stale closure
    setCount(count + 1)  // always sets 1
  }, 1000)
  return () => clearInterval(id)
}, [])  // ← empty deps captures count=0 forever

// ✅ CORRECT — functional update avoids stale closure
useEffect(() => {
  const id = setInterval(() => {
    setCount(prev => prev + 1)  // always gets latest value
  }, 1000)
  return () => clearInterval(id)
}, [])
5

Child Not Re-rendering When Parent Does

Parent updates but child displays stale data
2 min
ParentComponent.jsx
// ❌ WRONG — child reads from its own local state, not parent
function Parent() {
  const [items, setItems] = useState([1, 2, 3])
  return (
    <div>
      <button onClick={() => setItems([...items, items.length + 1])}>Add</button>
      <Child />    {/* Child has no connection to parent's items state */}
    </div>
  )
}

function Child() {
  const [items] = useState([1, 2, 3])  // its own state, never updates!
  return <ul>{items.map(i => <li key={i}>{i}</li>)}</ul>
}

// ✅ CORRECT — pass state as prop
function Parent() {
  const [items, setItems] = useState([1, 2, 3])
  return (
    <div>
      <button onClick={() => setItems(prev => [...prev, prev.length + 1])}>Add</button>
      <Child items={items} />   {/* receives updates as prop */}
    </div>
  )
}
function Child({ items }) {
  return <ul>{items.map(i => <li key={i}>{i}</li>)}</ul>
}
6

Force Re-render With key Prop

Reset a component completely
1 min
ParentComponent.jsx
// Changing key unmounts and remounts the component fresh
// Useful for: resetting forms, reinitialising third-party widgets

function Parent() {
  const [resetCount, setResetCount] = useState(0)

  return (
    <div>
      <ComplexForm key={resetCount} />  {/* changes key → fresh mount */}
      <button onClick={() => setResetCount(c => c + 1)}>Reset Form</button>
    </div>
  )
}

// Also useful for reinitialising when a prop changes:
// <UserProfile key={userId} userId={userId} />
// When userId changes → component fully remounts → no stale state

The key trick is the React team's own recommended way to reset component state. It is not a hack — it is an intentional pattern documented in the React docs.

Prevention

Frequently Asked Questions

Why is React component not re-rendering when state changes?+
React uses reference equality to detect changes. If you mutate an object or array directly (item.name = 'new') instead of creating a new one, the reference stays the same and React skips the re-render. Always create a new object/array with spread: setState(prev => ({ ...prev, name: 'new' })).
React state changes but UI does not update — how to fix?+
You are mutating state directly. Find where you write item.property = value or array.push() and replace with: setItems(prev => [...prev, newItem]) or setUser(prev => ({ ...prev, name: newName })). Never mutate state directly.
React.memo preventing needed re-render — how to fix?+
React.memo does shallow comparison. If a parent passes new object/function references on every render, memo sees different props and does re-render. If it is not re-rendering when it should, remove memo, test, then re-add with custom comparison if needed.
How do I force a React component to re-render?+
The cleanest way: change the key prop. When key changes, React unmounts and remounts the component fresh. Or add a forceUpdate state: const [, forceUpdate] = useReducer(x => x + 1, 0); forceUpdate(). Rarely needed — usually means state is structured incorrectly.
Child component not re-rendering when parent state changes?+
By default, children re-render whenever the parent re-renders. If a child is wrapped in React.memo and its props did not change (or appear unchanged due to same primitive values), it will not re-render. Pass the relevant state as a prop to force the child to receive it.
Component re-renders but shows old data — stale closure?+
The component is closing over an old value from a previous render. Fix by adding the variable to the useEffect dependency array, or use the functional update form: setState(prev => prev + 1) instead of setState(count + 1).

Need Expert Help?

We Build Production-Grade React Apps

Softplix builds full-stack React and Next.js applications. Dealing with complex rendering issues or performance problems? We can help.

Talk to an Engineer