Skip to content

Navigation Menu

Sign in
Sign up

Can't delete nested object from store #23

Open

Description

When used with unistore is impossible to delete / remove a nested object or property.
See the following example ( This code only works using unistore without stockroom )

// Store
const state = {
 collections: {
 items: {
 a: { ... },
 b: { ... },
 c: { ... },
 }
 // ...
 }
 // ...
}
// Action
removeItem({ collections }, id) {
 let items = collections.items;
 // Remove item
 if (items[id]) {
 const { [id]: removed, ...rest } = items;
 items = rest;
 }
 return { collections: { ...collections, items } };
},

Unistore only example (working demo)

Edit Unistore Demo

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      AltStyle によって変換されたページ (->オリジナル) /