Skip to content

Incorrect destructuring path in useStoreValue example #80

@gitkola

Description

@gitkola

Astro Info

The issue is about incorrect example in the docs and it is not related to Astro.

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Description

The README example shows incorrect destructuring from useStoreValue. The tags property is nested under meta, but the example destructures it at the top level.

What's the expected result?

Store Structure

const documentStore = store({
  title: "Untitled",
  authors: ["Ada", "Ben"],
  meta: {
    pages: 3,
    tags: ["draft", "internal"],
  },
});

Current (Incorrect) Code

const { title, tags } = useStoreValue(documentStore);

Expected (Correct) Code

Destructure nested property:

const { title, meta: { tags } } = useStoreValue(documentStore);

Impact

This may confuse new users about how to properly access nested store properties.

Location

README.md - Usage example section

Link to Minimal Reproducible Example

http://no-example.com

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions