0
Challenge · 32Hooks & Effects
React.memo
Performanceused in ~75% of apps
By default, when a component re-renders, React re-renders ALL of its children — even the ones whose props never changed. Usually that's cheap and fine. But when a child is genuinely expensive and keeps re-rendering with identical props, React.memo lets it skip the work.
Core idea. React.memo wraps a component so it SKIPS re-rendering when its props are shallow-equal (same references) to the previous render — switching off the default behavior where a child re-renders just because its parent did.
poke it, drag it,
try to break it
try to break it
no slides here.
you drive.
you drive.
Playground, this isn't a screenshot
Wrap child in React.memo?
Prop passed to child
// child component
function Child(props) { /* ... */ }
// inside Parent's JSX
<Child config={STABLE} /> // same reference every render
<Parent />rendered1×
renders its child
<Child />rendered1×
no memo: I re-render whenever my parent does.
No memo → the child re-renders on every parent render.
↑ play a little first, then dig in