how to define a tree-like model which the type of it's child is self?????
const DomNode = types.model('DomNode', {
id: types.identifier(),
animationAttr: types.array(types.string),
style: types.reference(DomStyle),
children: types.optional(types.array(DomNode), []),
edittable: types.maybe(types.boolean),
draggable: types.maybe(types.boolean)
})
then i get:
index.js:15817 Uncaught Error: [mobx-state-tree] expected a mobx-state-tree type as first argument, got undefined instead
the DomNode is undefined before it is created.
ha~ i found it. types.optional(types.array(types.late(()=>DomNode)), []), works well.
Most helpful comment
ha~ i found it.
types.optional(types.array(types.late(()=>DomNode)), []),works well.