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

Observable map cannot be replace with another observable map #1258

Closed
8 tasks done
pnpetrov opened this issue Nov 27, 2017 · 5 comments
Closed
8 tasks done

Observable map cannot be replace with another observable map #1258

pnpetrov opened this issue Nov 27, 2017 · 5 comments

Comments

@pnpetrov
Copy link

Since MobX v3.3.2 an observable map cannot be replaced with another observable map. I believe the only supported types are plain object, plain array and ES6 Map.

Error: [mobx] Invariant failed: Cannot get keys from ObservableMap@

Most probably related to:
Issue: #1243
MR: #1247

The getMapLikeKeys util function in #1247 does not take into account MobX maps. I think the isES6Map check must be replaced with isMapLike check which matches both ES6 Maps and MobX maps.

  1. Issue
  • Provide error messages including stacktrace
    Uncaught (in promise) Error: [mobx] Invariant failed: Cannot get keys from ObservableMap@71[{ }]
    at invariant (webpack-internal:///43:2372)
    at fail (webpack-internal:///43:2367)
    at getMapLikeKeys (webpack-internal:///43:2570)
    at eval (webpack-internal:///43:2287)
    at transaction (webpack-internal:///43:2068)
    at ObservableMap.replace (webpack-internal:///43:2283)

  • Provide a minimal sample reproduction.

const items = mobx.observable.map();
items.replace(mobx.observable.map())
  • Did you check this issue wasn't filed before?
    I couldn't find a similar issue

  • Elaborate on your issue. What behavior did you expect?
    MobX observable maps should be also supported for replacement (was working before v3.3.2)

  • State the versions of MobX and relevant libraries. Which browser / node / ... version?
    The issue is reproducible with MobX v3.3.2 only

  • Do you think others will benefit from this change as well and it should in core package (see also mobx-utils)?
    This scenario was working before v3.3.2 so...

  • Are you willing to (attempt) a PR yourself?
    I don't have a setup to build/test MobX but I would be glad to try

@mweststrate
Copy link
Member

mweststrate commented Nov 27, 2017 via email

@pnpetrov
Copy link
Author

Sure :)

@mweststrate
Copy link
Member

Fix released as 3.3.3. Thanks!

@pnpetrov
Copy link
Author

pnpetrov commented Dec 5, 2017

Thanks for the fix and sorry for the delay! It was a busy week and I did not have time to prepare the PR. Maybe next time :)

@mweststrate
Copy link
Member

mweststrate commented Dec 5, 2017 via email

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

2 participants