Skip to content

Commit 382de57

Browse files
authored
update Modifying values in arrays / Appending new values simplify. (#1189)
1 parent bca8d22 commit 382de57

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/routes/concepts/stores.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ Instead of relying on discovering individual indices, path syntax introduces sev
253253

254254
### Appending new values
255255

256-
To append a new element to an array within a store, you specify the target array and set the index to the desired position.
257-
For example, if you wanted to append the new element to the end of the array, you would set the index to `array.length`:
256+
To append new values to an array in a store, use the setter function with the spread operator (`...`) to create a new array that includes the existing items and the new ones.
257+
For appending a single element, you can instead leverage the "path syntax" by specifying the array’s length as the index to set.
258258

259259
```jsx
260260
setStore("users", (otherUsers) => [

0 commit comments

Comments
 (0)