Closed dodoto closed 2 years ago
Can you create a codesandbox example please.
On Mon, Sep 26, 2022 at 4:34 AM AD2012 @.***> wrote:
Question
- I've checked documentation and searched for existing issues
- I tried GitHub Discussions https://github.com/mobxjs/mobx-state-tree/discussions
I have two store provider with no relationship.
const StoreA = ModelA.create() const StoreB = ModelB.create()
{...elements} {...elements} When I use getRoot(StoreB.child), it always return StoreA. If I want get StoreB, what should I do?
— Reply to this email directly, view it on GitHub https://github.com/mobxjs/mobx-state-tree/issues/1965, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABCW4RMKCSS2RGOTSUNPBTWAFUZVANCNFSM6AAAAAAQVTK5SU . You are receiving this because you are subscribed to this thread.Message ID: @.***>
-- -Matt Ruby- @.***
It's my fault. getRoot works correctly. I reviewed my code and found I add store to root store. So when I use getRoot, it always returns root store. Now I use types.reference to solve the issue.
Question
I have two store provider with no relationship.
When I use getRoot(StoreB.child), it always return StoreA. If I want get StoreB, what should I do?