Course · Section 9: Data Structures, Modern Operators and Strings · Lecture 111: The Spread Operator (...)
State updates in React must not mutate. Implement `addItem(list, item)` returning a new array with `item` appended.
+ 1 hidden test run on Submit.
React decides whether to re-render by comparing references. push keeps the same array reference, so the change can be missed. Spreading into a new array with [...list, item] produces a new reference that includes the added item, which is what React expects from a state update.
Run your code to see results.