Training Grounds
Memo Doesn't HoldBlue Belt
+25 Ki
Description

A settings panel has a search input and a child component that displays the current theme. The child is wrapped in React.memo so it should only re-render when the theme changes.

Anomaly

Type anything in the search box ,the child's render counter climbs on every keystroke even though the theme never changed. React.memo appears to do nothing.

Constraint
Do not remove React.memo from the child component
Do not move the search input out of the parent
Hint

Think about what React.memo actually compares when it decides whether to skip a re-render.

Consult the SenseiOnly for those truly stuck · Flip to reveal

Think about what React.memo actually compares when it decides whether to skip a re-render.

Loading editor…
Correct Solution
Loading...

Why this fixes it

const config = { theme: "dark" } runs inside the component body on every render, creating a brand-new object at a new memory address each time. React.memo compares props by reference — {} !== {} even when the contents are identical, so the new reference caused the memo check to fail on every parent render, defeating it entirely. Wrapping the object in useMemo(() => ({ theme: "dark" }), []) produces the same reference across renders. React.memo now sees the same object, its comparison passes, and the child skips re-rendering.

Expected OutputGoal State
Your OutputLive