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
merging reconcile
without key duplicates the value
#57
Comments
Yeah. Internals are mutable so mutating the object outside produces unexpected results. That being said I think it's more that merge morphs everything in place and with it appearing in the object being reconciled it gets morphed to the new value. [B, A] -> [A] = [B, B] Because A becomes B, and then the second one is added. This is an interesting point though about Not sure how to formalize this limitation from a documentation standpoint. |
Thanks now I got it. I think it is good to clarify this in docs. For your reference I'd like to share my context why I tried to mutate the state outside store. I have a library to manipulate a tree structure data. The library is written in pure ECMAScript and has no dependencies (i.e. it doesn't know Solid). Each time the data is modified the library notifies to my app. I want to visualize this data with Solid, so I tried to To ensure that the values are never mutated outside store, now I have introduced a kind of viewmodel for the data to assign a store. It seems works well. |
Describe the bug
After solidjs/solid#1032 I'm still playing with
reconcile
... let me report another issue I found.An item
unshift
ed is duplicated byreconcile
:(Note that the
root
property at the top-level is to workaround solidjs/solid#1032.)Although I don't know the exact definition of
merge: true
, I think this is not an intended/expected behavior. As far as I confirmed, this duplication cannot be reproduced with one of the following modification:push
but notunshift
reconcile
withmerge: false
reconcile
withkey: "id"
root
object instead of reusing the value altered byroot.entries.unshift
I guess there are some (undocumented) limitation around reusing values when
merge: true
... or essentially it's inappropriate for arrays modified with splice or unshift.Your Example Website or App
https://playground.solidjs.com/?hash=575260739&version=1.4.1
Steps to Reproduce the Bug or Issue
"name": "ITEM 2 -- DUPLICATED!!!"
appear twice.Expected behavior
Screenshots or Videos
No response
Platform
Additional context
No response
The text was updated successfully, but these errors were encountered: