我正在尝试克隆一个引用另一个模型的模型,但我得到:Error: [mobx-state-tree] Failed to resolve reference 'H1qH2j20z' to type 'AnonymousModel' (from node: /usualCustomer)...
在克隆中。原版解决好了。
这是我的模型:
const Job = types.model({
id: types.optional(types.identifier(types.string), shortid.generate()),
jobNumber: types.optional(types.string, ''),
description: '',
usualCustomer: types.maybe(types.reference(Customer)),
})
const Customer = types.model({
id: types.optional(types.identifier(types.string), shortid.generate()),
name: types.optional(types.string, 'New customer'),
})
这个函数显示了问题:
editJob = job => {
console.log('Original', job)
var newClone = clone(job)
console.log('Clone', newClone)
}