Re-rendering means React calls your component function again to get a new element tree. It then reconciles that tree with the previous one and commits only the DOM changes that are actually needed. A re-render is not the same as a DOM update: many re-renders produce identical output and touch nothing. A component re-renders when its state changes, its parent re-renders, or a context it consumes changes. Props changing is not a trigger by itself. The parent re-rendering is.
root.render(), a state setter, a context value change, or (for the initial mount) hydration.function Parent() {
const [n, setN] = useState(0);
return (
<>
<button onClick={() => setN(n + 1)}>+</button>
<Child /> {/* re-renders on every click, even with no props */}
<Display value={n} />
</>
);
}
Object.is) usually bails out.Child re-renders even though nothing it uses changed.Usually no. Rendering is a JS function call plus a diff, and React is designed for it. It becomes a problem when:
children. Elements created by the parent keep the same identity when the wrapper's own state changes, so React skips them.function HoverCard({ children }) {
const [hover, setHover] = useState(false);
return <div onMouseEnter={() => setHover(true)}>{children}</div>; // children don't re-render
}
memo(Component) to skip re-rendering when props are shallow-equal, plus useMemo/useCallback for stable props. The React Compiler applies this automatically.useTransition/useDeferredValue to make expensive re-renders non-blocking.memo.children), then memoization or the Compiler.Spotted a mistake or a rights concern? Report an issue