1
我想在React项目中使用Mobx(使用Meteor)并使用mobx-react
创建全局通知存储。Mobx返回空对象
我尝试初始化模块,但我不知道为什么它返回一个空对象:
import { observable } from 'mobx';
class NotificationStore {
@observable notifications = ['test', 'new notification'];
}
var store = window.store = new NotificationStore;
export default store;
在我App.js:
import store from '../../components/NotificationStore';
console.log(store); // return Object { }
任何人都知道为什么我的对象是空的 ?
谢谢社区!
这很奇怪。它工作[**为我**](http://jsbin.com/cenibayuyi/1/edit?js,console,output)。也许你会在代码中的其他地方覆盖'window.store'? – Tholle
嗨!在你的例子中,空的对象也是,nop? –
写'store.notifications.toJS()',你会看到值。 – Tholle