developit / developit/stockroom

Can't delete nested object from store

Open
#23 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.7k
Forks
44
PR merge metrics
No merged PRs in 30d

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` )

``` JSX
// 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](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/k6v6j6y97?fontsize=14)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.