Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reconcile problem when array should replace an object #1973

Closed
jcmonnin opened this issue Dec 5, 2023 · 1 comment
Closed

reconcile problem when array should replace an object #1973

jcmonnin opened this issue Dec 5, 2023 · 1 comment

Comments

@jcmonnin
Copy link

jcmonnin commented Dec 5, 2023

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

@raviqqe
Copy link

raviqqe commented Jun 6, 2024

The fix seems to be deployed to the npm registry. But I still see the problem on v1.8.17. https://github.com/raviqqe/til/blob/9b08c2db269100e6eac19dd7c10ef73e4788cc86/solid-array-store/src/store.test.ts#L32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants