I'm trying to clone a model that references another model, but I get: Error: [mobx-state-tree] Failed to resolve reference 'H1qH2j20z' to type 'AnonymousModel' (from node: /usualCustomer)...
in the clone. The original resolves okay.
Here are my models:
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'),
})
This function shows the problem:
editJob = job => {
console.log('Original', job)
var newClone = clone(job)
console.log('Clone', newClone)
}