React · Middle · Question 4 of 75

Why doesn't memo help <List items={data} onSelect={() => select(id)} style={{ gap: 8 }} />?

Explanation

An inline function and an object literal are new references on every render, so shallow comparison won't let them through. Stabilize them with useCallback / useMemo, or move constants outside the component. The React Compiler does this automatically.

Further reading

Problem with a question

React · Middle · question 4

Test yourself

Take the React · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz