2
我已經實現了這一點,但店裏沒有值(所有未定義):陣營mobx不注門店正常
這是商店:
export default class AppState {
// Is authenticated
@observable authenticated;
@action get authenticated() {
return this.authenticated;
}
doSomethingWithNoDecorator() {
return this.authenticated;
}
}
這是index.js:
const stores = {
AppState
};
const renderApp = Component => {
render(
<AppContainer>
<Provider { ...stores }>
<Router>
// Routes
</Router>
</Provider>
</AppContainer>,
document.getElementById("root")
);
};
這是組件:
@inject("AppState")
@observer
export default class SidebarListItem extends Component {
constructor(props) {
super(props)
this.store = this.props.AppState;
}
doSomething() {
this.store.authenticated();
this.store.doSomethingWithNoDecorator();
this.store.authenticated;
}
}
商店不是空...我可以看到該功能。但我無法獲取任何字段或調用任何方法。
我做錯了什麼?
問候, Idob