Skip to content

[Content]: Top-Level Array ExampleΒ #1094

Open
@chasingtheflow

Description

@chasingtheflow

πŸ“š Subject area/topic

/concepts/stores.mdx

πŸ“‹ Page(s) affected (or suggested, for new content)

It would be nice if this also showed how to deal with a top-level array in the store. These examples walk to the array as a property of the store object but it indicates that the store could also be an array and the syntax for dealing with a top level array seems like it would have to be different.

πŸ“‹ Description of content that is out-of-date or incorrect

const [store, setStore] = createStore({
  userCount: 3,
  users: [ ... ],
})

setStore("users", (currentUsers) => [
  ...currentUsers,
  {
    id: 3,
    username: "michael584",
    location: "Nigeria",
    loggedIn: false,
  },
])```

If the example users array was the store itself (`createStore([...users])`) then wouldn't most of the modifying examples be different?

### πŸ–₯️ Reproduction in StackBlitz (if reporting incorrect content or code samples)

_No response_

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomershelp wantedLooking for assistance on this issuesolidRelated to core Solid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions