QuizNot attempted
useMemo with a new array each render
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
- Yes, because
useMemocompares by reference (Object.is), and the new array is a different reference
[...items]is a new array, and dependency comparison isObject.is(reference), so the memo sees a change and recomputes even though the contents are equal.- Not 'no, values identical': React never deep-compares dependencies.
- Not 'only if count changes':
countisn't a dependency. - Not 'throws': this is valid code.