更新 mobx 存储值后未调用组件的 render()
component's render() is not getting invoked after updating mobx store value
在从服务器获取数据之前更新存储,工作正常。但是在从服务器获取数据并更新存储之后,render() 方法没有被调用
code snippet
@action
static getPartner(partnerParams) {
store.invitationDetails.invitingOrgPartnerName = ""; // here render() is getting invoked
fetchPartner(partnerParams)
.then((data) => data.json())
.then(function (result) {
if (result.success) {
if (result.alreadyPartner) {
runInAction(() => {
store.invitationDetails.invitingOrgPartnerName = result.partnerName; // here render() is NOT getting invoked
});
}
}
})
.catch((e) => {
console.info("Failed getting partners", e);
});
}
Mobx works perfectly in most of the cases but not always
你应该使用 extendObservable
请关注这个ExtendObservable
在从服务器获取数据之前更新存储,工作正常。但是在从服务器获取数据并更新存储之后,render() 方法没有被调用 code snippet
@action
static getPartner(partnerParams) {
store.invitationDetails.invitingOrgPartnerName = ""; // here render() is getting invoked
fetchPartner(partnerParams)
.then((data) => data.json())
.then(function (result) {
if (result.success) {
if (result.alreadyPartner) {
runInAction(() => {
store.invitationDetails.invitingOrgPartnerName = result.partnerName; // here render() is NOT getting invoked
});
}
}
})
.catch((e) => {
console.info("Failed getting partners", e);
});
}
Mobx works perfectly in most of the cases but not always
你应该使用 extendObservable 请关注这个ExtendObservable