Since the last update of Mobx 3.6 to Mobx 4, my application just stopped working. I'm using react-native and I just followed the instructions to migrate to the newest features, but my application just keeps crashing displaying the following error:
[mobx] There are multiple mobx instances active. This might lead to unexpected results: See https://github.com/mobxjs/mobx/issues/1082 for details.
Click here to check the error image
Mobx store:
I just created a simple observable object, with the following code:
import React, { Component } from "react";
import { observable } from "mobx";
const ProductsStore = observable.object(
{
selectedProduct: null,
products: [
{
id: 1,
name: "NVIDIA 1050TI",
desc: "4GB OC",
model: "ASUS",
price: 1050,
quantity: 1
},
{
id: 2,
name: "NVIDIA 1060TI",
desc: "6GB OC",
model: "EVGA",
price: 1050,
quantity: 1
},
{
id: 3,
name: "NVIDIA 1070TI",
desc: "8GB OC",
model: "MSI",
price: 1050,
quantity: 1
},
{
id: 4,
name: "NVIDIA 1080TI",
desc: "11GB OC",
model: "FOUNDERS EDITION",
price: 1050,
quantity: 1
}
]
},
{ selectedProduct: observable, products: observable }
);
export { ProductsStore };
But, when I try to import this file, it will crash the application and it will display the error that I've mentioned before.
import { ProductsStore } from '@store'
I've tried without the alias, but it seems it's not working.
tree -d | grep mobx
to quickly check. If it is unique, you might have linked packages into your project that also contain mobx.