Skip to content

InvalidReferenceError: [mobx-state-tree] Failed to resolve... #2258

Answered by thegedge
OnkelTem asked this question in Q&A
Discussion options

You must be logged in to vote

I don't have "stores", I have a number of connected models. So how do I connect them then?

With a store, or something like that 🙂

But it helps to explain why! References are resolved within the tree they're part of, but they can't resolve identifiers across different trees. For you, foo and bar are two separate trees (specifically, they're the roots of two trees). In the docs example, everything is under one tree rooted at storeInstance, so that's why the references can resolve.

For example, for you, it could look like this:

import { getSnapshot, types } from 'mobx-state-tree'

const fooModel = types.model({
  id: types.identifier,
  title: types.string,
})

const barModel = types.model({

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@OnkelTem
Comment options

@thegedge
Comment options

Answer selected by OnkelTem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants