Skip to content

Document reconcile() in-place mutation caveat - #28

Open
rajanpanth wants to merge 1 commit into
nanostores:masterfrom
rajanpanth:docs/27-reconcile-caveat
Open

Document reconcile() in-place mutation caveat#28
rajanpanth wants to merge 1 commit into
nanostores:masterfrom
rajanpanth:docs/27-reconcile-caveat

Conversation

@rajanpanth

Copy link
Copy Markdown

Fixes #27

Documents the reconcile() behaviour reported in #27: useStore applies every update with Solid's reconcile(), so for object/array values the previous object is mutated in place to match the new one — a footgun when the store holds references to objects you don't own (e.g. proxies from another library).

The new README section explains:

  • why reconcile() is used (fine-grained rendering) and that the useStore second argument passes through as ReconcileOptions (e.g. key for array stores) — previously undocumented;
  • the in-place mutation consequence;
  • a deep-copy workaround, adapted from @stewartadam's snippet in the issue (thanks!).

Docs-only change. I left the rest of the README untouched (it is not prettier-formatted, so no formatting churn).

useStore applies updates with Solid's reconcile(), which mutates the
previous object value in place to match the new one. Document that
consequence — storing references to external proxy objects is a
footgun — plus the ReconcileOptions pass-through and a deep-copy
workaround, per the report in nanostores#27.
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

Successfully merging this pull request may close these issues.

Consider documenting use of reconcile(), which can mutate existing values in the store when setting a new one

1 participant