Skip to content

update Modifying values in arrays / Appending new values simplify. #1189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mizulu
Copy link
Contributor

@mizulu mizulu commented May 27, 2025

current

To append a new element to an array within a store,
you specify the target array and set the index to the desired position. For example, 
if you wanted to append the new element to the end of the array, 
you would set the index to array.length:

this phrasing may be a little ambiguous, the example for appending, using the path syntax, will always use the array.length to append a value.

To append a new element to an array within a store,
you specify the target array and set the index to the desired position.

may imply to readers that read this section without prior context that the index can be used as insertion point in the array. not realizing that only works with non existing index such as the length, or higher index

  • [x ] I have read the Contribution guide
  • This PR references an issue (except for typos, broken links, or other minor problems)

Description(required)

proposing or revised explanation, that focuses on the usage of array.length as an alternative
"shortcut" to using a setter function and a spread for a "appending of a single value"

feedback from discord
image

Related issues & labels

Stores
https://docs.solidjs.com/concepts/stores#appending-new-values

current 

```Appending new values
To append a new element to an array within a store, you specify the target array and set the index to the desired position. For example, if you wanted to append the new element to the end of the array, you would set the index to array.length:
```

this phrasing may be a little ambiguous, the example for appending, using the path syntax, will always use the array.length 
to append a value. 

> and set the index to the desired position
may imply to readers that read this section without prior context
that the index can be used as insertion point in the array. 
not realizing that only works with non existing index such as the length, or higher index
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

netlify bot commented May 27, 2025

Deploy Preview for solid-docs ready!

Name Link
🔨 Latest commit 104b94e
🔍 Latest deploy log https://app.netlify.com/projects/solid-docs/deploys/6835fb6b5e6910000823eefa
😎 Deploy Preview https://deploy-preview-1189--solid-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant