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

UNCHANGED doesn't equal UNCHANGED when I npm link a library which is using mobx #1742

Closed
capaj opened this issue Sep 27, 2018 · 4 comments
Closed

Comments

@capaj
Copy link
Member

capaj commented Sep 27, 2018

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

export const UNCHANGED: IUNCHANGED = {}

which is being compared to a newValue here:

newValue = (observable as any).prepareNewValue(newValue) as V
if (newValue !== UNCHANGED) {
const notifySpy = isSpyEnabled()

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?

@mweststrate
Copy link
Member

@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 :)

@mweststrate
Copy link
Member

Created fix, will be part of next version

@mweststrate
Copy link
Member

Released in 4.7.0 / 5.7.0

@lock
Copy link

lock bot commented Jul 21, 2019

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.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants