What type do you use to store an object as property that does not belong to a model? #1891
Answered
by
EmilTholin
andrewdang17
asked this question in
Q&A
-
I'm confused by the types documentation since there's not really any examples. Say I have a |
Beta Was this translation helpful? Give feedback.
Answered by
EmilTholin
Mar 30, 2022
Replies: 1 comment
-
Hi @andrewdang17! If the nested models are used just for the import { types } from "mobx-state-tree";
const User = types.model({
id: types.identifier,
name: types.string,
pictures: types.model({
versions: types.model({
original: types.string,
thumbnail: types.string
})
})
});
const user = User.create({
id: "1",
name: "John Doe",
pictures: {
versions: {
original: "http://placekitten.com/800/800",
thumbnail: "http://placekitten.com/200/200"
}
}
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
andrewdang17
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @andrewdang17!
If the nested models are used just for the
User
you can inline them if you prefer: