解决子 store 不更新的问题
This commit is contained in:
parent
64751163b5
commit
0d12d793e4
|
@ -728,20 +728,18 @@ export function HocStoreFactory(renderer: {
|
|||
);
|
||||
} else if (isObjectShallowModified(props.data, nextProps.data)) {
|
||||
if (nextProps.store && nextProps.store.data === nextProps.data) {
|
||||
const diff = syncDataFromSuper(
|
||||
store.data,
|
||||
nextProps.store.data,
|
||||
props.scope,
|
||||
nextProps.dataUpdatedAt !== props.dataUpdatedAt,
|
||||
store
|
||||
store.initData(
|
||||
createObject(
|
||||
nextProps.store.data,
|
||||
syncDataFromSuper(
|
||||
store.data,
|
||||
nextProps.store.data,
|
||||
props.scope,
|
||||
nextProps.dataUpdatedAt !== props.dataUpdatedAt,
|
||||
store
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if (Object.keys(diff).length) {
|
||||
const newData = createObject(nextProps.store.data, diff);
|
||||
|
||||
// todo fix: dialog 种数据从孩子 form 同步过来后,会走这个逻辑让 form 更新 data,会导致里面的 __prev 丢失。
|
||||
store.initData(newData);
|
||||
}
|
||||
} else if (nextProps.data && (nextProps.data as any).__super) {
|
||||
store.initData(extendObject(nextProps.data));
|
||||
} else {
|
||||
|
|
|
@ -34,7 +34,7 @@ export class Chart extends React.Component<ChartProps> {
|
|||
echarts: any;
|
||||
unSensor: Function;
|
||||
pending?: object;
|
||||
timer: number;
|
||||
timer: NodeJS.Timeout;
|
||||
mounted: boolean;
|
||||
reloadCancel: Function;
|
||||
|
||||
|
@ -148,6 +148,9 @@ export class Chart extends React.Component<ChartProps> {
|
|||
cancelExecutor: (executor: Function) => (this.reloadCancel = executor)
|
||||
})
|
||||
.then(result => {
|
||||
if (!result.ok) {
|
||||
return env.notify('error', result.msg || '加载失败,请重试!');
|
||||
}
|
||||
delete this.reloadCancel;
|
||||
this.renderChart(result.data || {});
|
||||
this.echarts && this.echarts.hideLoading();
|
||||
|
|
Loading…
Reference in New Issue