Mobx: UNCHANGED doesn't equal UNCHANGED when I npm link a library which is using mobx

Created on 27 Sep 2018  ·  4Comments  ·  Source: mobxjs/mobx

So I was having a fun afternoon trying to figure out why mu observable is being populated with an empty object instead of my value when I call set().

There is this UNCHANGED
https://github.com/mobxjs/mobx/blob/f944b5413f2f4b9de89e00e7de1ddde2a178e19d/src/types/observablevalue.ts#L36

which is being compared to a newValue here:
https://github.com/mobxjs/mobx/blob/f944b5413f2f4b9de89e00e7de1ddde2a178e19d/src/types/observablemap.ts#L185-L187

And in my case the prepareNewValue() indeed returned UNCHANGED, but it didn't equal even though my newValue was the same as current value.

Look:

image

I stored the other UNCHANGED on my window and that equaled.
The reason why it doesn't equal is that I used npm link to load up a different version of mobx. And since webpack then loads multiple modules of mobx, when you use a set from one on another it just does really weird stuff.

Worst thing is-not even a peer dependency helps.
@mweststrate wasn't there some kind of warning when you loaded up multiple mobx modules at once?

❔ question 🐛 bug

All 4 comments

@capaj I think this one could be fixed by storing UNCHANGED on the global state object instead of having it as module constant. Note that it might not be the last of your issues though, and if you could prevent linking / multiple instances that would be better :)

Created fix, will be part of next version

Released in 4.7.0 / 5.7.0

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or questions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cafreeman picture cafreeman  ·  4Comments

ansarizafar picture ansarizafar  ·  4Comments

mehdi-cit picture mehdi-cit  ·  3Comments

bb picture bb  ·  3Comments

etinif picture etinif  ·  3Comments