Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/mobx-state-tree/src/types/utility-types/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ class StoredReference<IT extends IAnyType> {

if (!target) {
throw new InvalidReferenceError(
`[mobx-state-tree] Failed to resolve reference '${this.identifier}' to type '${
this.targetType.name
}' (from node: ${node.path})`
`[mobx-state-tree] Failed to resolve reference '${this.identifier}' to type '${this.targetType.name}' (from node: ${node.path})`
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not change this, prettier did 😉

)
}

Expand Down Expand Up @@ -567,11 +565,15 @@ export function safeReference<IT extends IAnyComplexType>(
subType: IT,
options?: (ReferenceOptionsGetSet<IT> | {}) & {
acceptsUndefined?: boolean
onInvalidated?: OnReferenceInvalidated<ReferenceT<IT>>
}
): IReferenceType<IT> | IMaybe<IReferenceType<IT>> {
const refType = reference(subType, {
...options,
onInvalidated(ev) {
if (options && options.onInvalidated) {
options.onInvalidated(ev)
}
ev.removeRef()
}
})
Expand Down