У меня есть магазин Mobx, и я передаю этот магазин внутри провайдера, и когда я утешаюсь this.props показывает структуру магазина Mobx.
Ниже мой магазин Mobx
import { observable, computed, action, useStrict, runInAction, toJS } from 'mobx';
// useStrict(true);
class OpenPropertiesStore {
@observable openProperties = {};
@action
fetchOpenProperties() {
fetch(`http://uinames.com/api/`)
.then(res => res.json())
.then(data => {
runInAction(() => {
this.openProperties = data;
this.name = "abhinav";
})
})
}
@computed get getOpenProperties() {
return this.openProperties;
}
}
export default new OpenPropertiesStore();
Внутри компонента я вызываю ComponentDidMount, где, если я печатаю «this.props», он показывает магазин.Но я не могу вызвать функцию, подобную этой
@inject('UserStore', 'CityStore', 'OpenPropertiesStore')
@observer
export default class Navigation extends Component {
componentDidMount = async () => {
const { CityStore, UserStore, OpenPropertiesStore } = this.props;
const data = OpenPropertiesStore.getOpenProperties();
}
}
, сообщая мне об ошибке
YellowBox.js: 67 Возможный необработанный отказ от обещания (id: 0): TypeError: OpenPropertiesStore.getOpenPropertiesне является функцией TypeError: OpenPropertiesStore.getOpenProperties не является функцией
Кто-нибудь знает, как решить эту ошибку