Quite often we see warning like this when data is consumed by antd Table:
Warning: Failed prop type: Invalid prop `dataSource` of type `object` supplied to `Table`, expected `array`.
I tried .toJSON() but it's undefined. So I have to use .concat() somehow. But what's the right way to get JSON from it?
getSnapshot. Or if the component is observer; change the prop type, mst
arrays are objects
On wo 1 nov. 2017 03:42 jiyinyiyong notifications@github.com wrote:
Quite often we see warning like this when data is consumed by antd Table:
Warning: Failed prop type: Invalid prop
dataSourceof typeobjectsupplied toTable, expectedarray.I tried .toJSON() but it's undefined. So I have to use .concat() somehow.
But what's the right way to get JSON from it?—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/mobxjs/mobx-state-tree/issues/500, or mute the thread
https://github.com/notifications/unsubscribe-auth/ABvGhIDBNN3-if4sdMHLJaMpY1FNBh9Xks5sx9qDgaJpZM4QNrPy
.
noticed there is actually a .toJSON() method in the runtime. but TypeScript tells me that no method called .toJSON(). Maybe it's because the type is types.maybe? Or a bug in types.
.toJSON is just an alias for getSnapshot, so you should use that instead :)
BTW do you have any idea on dealing with null values in the tree? Currently I have to use:
s ? getSnapshot(s) : []
You could use isStateTreeNode(v) ? GetSnapshot(v) : V :)
Since we have data from both MobX and mobx-state-tree. Now we have a problem:
export function toJSObject(obj: any) {
if (!obj) {
return obj;
}
if (obj.toJS) {
return obj.toJS();
} else if (obj.toJSON) {
return obj.toJSON();
} else {
return obj;
}
}
Didn't read previous messages, but why not isStateTreenode(v) ?
getSnapshot(v) : isObservableObject(v) ? toJS(v) : etc...
Op ma 6 nov. 2017 om 05:36 schreef jiyinyiyong notifications@github.com:
Since we have data from both MobX and mobx-state-tree. Now we have a
problem:export function toJSObject(obj: any) {
if (!obj) {
return obj;
}if (obj.toJS) {
return obj.toJS();
} else if (obj.toJSON) {
return obj.toJSON();
} else {
return obj;
}
}—
You are receiving this because you commented.Reply to this email directly, view it on GitHub
https://github.com/mobxjs/mobx-state-tree/issues/500#issuecomment-342044560,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABvGhL3kB-rAZ515ckD7D5DnBUJmBKADks5szoy7gaJpZM4QNrPy
.
Do isStateTreenode and isObservableObject handle null issues? I got errors when I was trying those functions. (Didn't go to details...)
They should return false on null
Op ma 6 nov. 2017 om 12:08 schreef jiyinyiyong notifications@github.com:
Do isStateTreenode and isObservableObject handle null issues? I got
errors when I was trying those functions. (Didn't go to details...)—
You are receiving this because you commented.Reply to this email directly, view it on GitHub
https://github.com/mobxjs/mobx-state-tree/issues/500#issuecomment-342117611,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABvGhCNFrcwA__Y78o47FXHfZ50mDnkIks5szujLgaJpZM4QNrPy
.
not going to dig into the code yet. but it confused my why mobx and mox-state-tree has two different data types. plus I got an error:

I think it remains a problem on my side to convert data among mobx-state-tree, mobx, and plain JavaScript object(need to be extensible). Our app has grown to near 200 .ts(x) files with nearly 30 models defined. It made me think whether it's the right way to use all of them inside.
Got an idea, since MST is using MobX, toJS method in MobX should work for MST data too...
https://github.com/mobxjs/mobx/blob/016b75f651839e0287a11b265a9b1ce964012c5f/src/api/tojs.ts#L13