How to work with nested objects? #142
anton-at-bay
announced in
Announcements
Replies: 1 comment 1 reply
-
There is no special API and we do not plan to add API to the core to keep core minimalistic. Here are options:
state.setKey(2, { ...state.get()[2], street: 'New' })
export function changeState(id, key, value) {
state.setKey(id, { ...state.get()[id], [key]: value })
} import { changeState, state } from '../stores/state'
changeState(id, 'street', 'New') |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello all,
Thanks for the nanostores, my goto tool to handle state in all types of projects 🙏
I haven't found a way to handle nested objects update when using the map.
How do I update street for the second item?
Many thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions