Repository navigation
Replies: 1 comment
|
import { observable, toJS, isObservable } from 'mobx';
const sourceMap = observable.map([['one', { value: 1 }]]);
const plainMap = toJS(sourceMap);
const object = Object.fromEntries(plainMap);
const sourceSet = observable.set(['a', 'b']);
const plainSet = toJS(sourceSet);
const array = Array.from(plainSet);
console.log(plainMap instanceof Map, isObservable(plainMap)); // true false
console.log(plainSet instanceof Set, isObservable(plainSet)); // true false
console.log(JSON.stringify(object)); // {"one":{"value":1}}
console.log(JSON.stringify(array)); // ["a","b"]Use I tested this example with MobX 6.15.0 and 7.0.6, including a non-observable nested result. See |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi, I'm trying to migrate a codebase from mobx5 to mobx6 and unfortunately we were using Maps and Sets that were converted to plain JS structures using
toJS()which no longer converts Maps and Sets in mobx6.I've tried a mix of these methods
but nothing seems to be working unfortunately 😢
Any suggestion? Thank you
All reactions