背景:
React项目中使用了MoBx之后发报
Error: [mobx] There are multiple mobx instances active. This might lead to unexpected results. See https://github.com/mobxjs/mobx/issues/1082 for details.
问题点:
重复引用了多个MoBx
解决方案:
查看所有引用MoBx的地方的引用路径是否相同?
检查发现有一处引用路径不同,修改为统一的路径后OK!
import {observer} from "mobx-react";
import "./Form.css";
import ModalStore from "../../stores/ModalStore";
// import {action} from "mobx/lib/mobx"; // 问题点
import {action} from "mobx"; // 正确路径