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

Strange bug using dset with mobx #27

Open
filippodossena-mozart opened this issue Oct 7, 2021 · 0 comments
Open

Strange bug using dset with mobx #27

filippodossena-mozart opened this issue Oct 7, 2021 · 0 comments

Comments

@filippodossena-mozart
Copy link

I noticed that there is a weird bug when using dset with mobx:

dset(data, "a.b.c", 1)

If data is an mobx observable (a deep and proxied one), dset will set only the first key a with an empty object.
The result will be:

{ a: {} }

instead of

{ a: { b: { c: 1 } } }

It happens only when using deep and proxy options in mobx (that are the default options).

Struggling with it, I found out that it is the multiple assignment used in dset function that breaks it.
It can be fixed splitting the multiple assignment into 2 different lines.

I created a sandbox that shows everything I state here (fix included):
https://codesandbox.io/s/dset-mobx-issue-x99gw

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

1 participant