Common mistakes
Common mistakes in the Lists and keys guide.
- Using the array index as the key. After an insert or a removal every key shifts; rows are reused for the wrong data. Use an id.
- Rebuilding objects on every update (
items().map((item) => ({ ...item }))) with an unkeyedFor. Every reference is new, so every row is rebuilt. Keep references, or addkey. - Treating
itemas an accessor in the unkeyed form, or as a value in the keyed form. Unkeyed:item.title. Keyed:item().title.Indexalways gives an accessor. - Using
Indexfor objects that get reordered. Position rows rewriteitem()on every row instead of moving nodes. - Mutating the array in place outside a store (
list().push(x)). Nothing notifies. Write a new array to the signal, or use a store. - A key that is not stable (
key={() => Math.random()}, a fresh object). Rows are rebuilt on every update.