Frontend & browser·State, data and re-rendering
you built a new array with the change in it instead of pushing onto the one you already had.
Immutable update
Also calledimmutability, copy on write
Producing a new value rather than mutating the existing one, so that a shallow comparison can detect the change. It is not an aesthetic preference in a component framework: mutation in place is invisible to change detection, so the update simply does not render. The cost is allocation and the awkwardness of deep updates, which is what libraries with a draft-based API exist to hide.