Strange bug using dset with mobx
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 783
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the dset function and reproduce the deep, proxied MobX case using the linked CodeSandbox. Compare the current result with the expected nested object and verify the behavior after the reported assignment change; the work is done when the nested path is written correctly without breaking ordinary dset usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100