[x] I've checked documentation and searched for existing issues
[x] I've made sure my project is based on the latest MST version
[x] Fork this code sandbox or another minimal reproduction.
Sandbox link or minimal reproduction code
const ModelA = types.model({
id: types.identifier,
n: types.number
}).actions(self => ({
setN(aNumber: number) {
self.n = aNumber
}
}))
const ModelB = types.model({
refA: types.reference(ModelA)
})
const a = ModelA.create({ id: 'someId', n: 5 });
// this will allow the compiler to use a model as if it were a reference snapshot
const b = ModelB.create({ refA: castToReferenceSnapshot(a)})
console.log(b.refA.n);
Describe the expected behavior5 should be logged to the console.
Describe the observed behavior[mobx-state-tree] Failed to resolve reference 'someId' to type 'AnonymousModel' (from node: /refA)
Bug report
Sandbox link or minimal reproduction code
Describe the expected behavior
5
should be logged to the console.Describe the observed behavior
[mobx-state-tree] Failed to resolve reference 'someId' to type 'AnonymousModel' (from node: /refA)
Notes This example code comes directly from the documentation of
castToReferenceSnapshot
: https://mobx-state-tree.js.org/API/#casttoreferencesnapshot