fix: 调整 chart 初始加载时机 & dialog drawer 可能存在数据不同步的情况修复

This commit is contained in:
2betop 2021-07-05 12:33:58 +08:00
parent 6322fee073
commit cce4069569
3 changed files with 12 additions and 7 deletions

View File

@ -177,19 +177,20 @@ export class Chart extends React.Component<ChartProps> {
this.refFn = this.refFn.bind(this);
this.reload = this.reload.bind(this);
this.handleClick = this.handleClick.bind(this);
const {config, api, data, initFetch, source} = props;
this.mounted = true;
props.config && this.renderChart(props.config);
}
componentDidMount() {
const {api, data, initFetch, source} = this.props;
if (source && isPureVariable(source)) {
const ret = resolveVariableAndFilter(source, data, '| raw');
ret && this.renderChart(ret);
} else if (api && initFetch !== false) {
this.reload();
}
config && this.renderChart(config);
}
componentDidUpdate(prevProps: ChartProps) {

View File

@ -604,7 +604,9 @@ export default class Dialog extends React.Component<DialogProps> {
isolateScope: true,
shouldSyncSuperStore: (store: IServiceStore, props: any, prevProps: any) =>
(store.dialogOpen || props.show) &&
isObjectShallowModified(prevProps.data, props.data)
(props.show !== prevProps.show ||
isObjectShallowModified(prevProps.data, props.data) ||
isObjectShallowModified(prevProps.data.__super, props.data.__super))
})
export class DialogRenderer extends Dialog {
static contextType = ScopedContext;

View File

@ -656,7 +656,9 @@ export default class Drawer extends React.Component<DrawerProps> {
isolateScope: true,
shouldSyncSuperStore: (store: IServiceStore, props: any, prevProps: any) =>
(store.drawerOpen || props.show) &&
isObjectShallowModified(prevProps.data, props.data)
(props.show !== prevProps.show ||
isObjectShallowModified(prevProps.data, props.data) ||
isObjectShallowModified(prevProps.data.__super, props.data.__super))
})
export class DrawerRenderer extends Drawer {
static contextType = ScopedContext;