-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Describe the bug
Setting a getter-function on a key that has already been initialized in a store with setStore will not create a reactive getter, unlike when you set the getter-function while initializing a key.
This can be solved (as @thetarnav suggested) by doing a shallow merge.
setStore({
alreadyDefinedKey: {
get get() {
return store.value;
},
},
});
but this feels like it should be supported without having to shallow merge objects (i personally try to avoid shallow merging as much as possible, because of the fact you can accidentally create multiple paths leading to the same reactive value and that can have unexpected results)
Your Example Website or App
https://playground.solidjs.com/anonymous/972b3aec-d7df-4ec0-9a68-c8b8b60785e3
Steps to Reproduce the Bug or Issue
const [store, setStore] = createStore({ value: 0, alreadyDefinedKey: {}});
setStore('alreadyDefinedKey', {
get get() {
return store.value
}
})
setStore('newKey', {
get get() {
return store.value
}
})
setStore('value', 1)
Expected behavior
I expect in the above example store.alreadyDefinedKey.get to be 1, just as store.newKey.get, but instead it is the old value 0.
Screenshots or Videos
No response
Platform
- OS: iOS
- Browser: firefox
- Version: 12.1.1
Additional context
No response