-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Describe the bug
I have a data structure coming as JSON from the server that is put in a store. When a new state from server comes, reconcile is used to update the store in order to keep fine grained updates.
When there is an existing object in store, which should be an array after store update, reconcile shows strange behavior.
Your Example Website or App
https://playground.solidjs.com/anonymous/ab7db9d8-47b6-4fd7-8f0b-fda541030b92
Steps to Reproduce the Bug or Issue
The example below shows the strange behavior of reconcile
const [store, setStore] = createStore({"a":{"b":1}});
setStore(reconcile({"a":[{"b": 1}]}));
console.log("with reconcile", JSON.stringify(store));
outputs:
with reconcile {"a":{"0":{"b":1},"b":1}}
Expected behavior
When not using reconcile the store has the expected state:
const [store, setStore] = createStore({"a":{"b":1}});
setStore({"a":[{"b": 1}]});
console.log("without reconcile", JSON.stringify(store));
outputs:
without reconcile {"a":[{"b":1}]}
Screenshots or Videos
No response
Platform
- OS: [e.g. macOS, Windows, Linux]
- Browser: [e.g. Chrome, Safari, Firefox]
- Version: [e.g. 91.1]
Additional context
No response
Metadata
Metadata
Assignees
Labels
No labels