mirror of https://gitee.com/antv-l7/antv-l7
perf(react): 优化react组件更新逻辑
This commit is contained in:
parent
7167c3197e
commit
53a99b7ea8
|
@ -13,8 +13,7 @@ export default React.memo(function Chart(props: ILayerProps) {
|
|||
color.field
|
||||
? layer.color(color.field as StyleAttrField, color.values)
|
||||
: layer.color(color.values as StyleAttrField);
|
||||
// TODO:目前这种处理会频繁更新,但是直接JSON.Stringify(size.values),回调函数不会更新,待优化
|
||||
}, [color.field, color.scale, color.values]);
|
||||
}, [color.field, color.scale, JSON.stringify(color.values), JSON.stringify(color.options)]);
|
||||
|
||||
return null;
|
||||
});
|
||||
|
|
|
@ -13,6 +13,6 @@ export default React.memo(function Chart(props: ILayerProps) {
|
|||
if (filter.field) {
|
||||
layer.filter(filter.field as string, filter.values as StyleAttrField);
|
||||
}
|
||||
}, [filter.field, filter.values, JSON.stringify(filter.values)]);
|
||||
}, [filter.field, filter.values, JSON.stringify(filter.values), JSON.stringify(filter.options)]);
|
||||
return null;
|
||||
});
|
||||
|
|
|
@ -13,6 +13,6 @@ export default React.memo(function Chart(props: ILayerProps) {
|
|||
shape.field
|
||||
? layer.shape(shape.field, shape.values)
|
||||
: layer.shape(shape.values as StyleAttrField);
|
||||
}, [shape.field, JSON.stringify(shape.values)]);
|
||||
}, [shape.field, JSON.stringify(shape.values), JSON.stringify(shape.options)]);
|
||||
return null;
|
||||
});
|
||||
|
|
|
@ -13,7 +13,6 @@ export default React.memo(function Chart(props: ILayerProps) {
|
|||
size.field
|
||||
? layer.size(size.field, size.values)
|
||||
: layer.size(size.values as StyleAttrField);
|
||||
// TODO:目前这种处理会频繁更新,但是直接JSON.Stringify(size.values),回调函数不会更新,待优化
|
||||
}, [size.field, size.values, size.scale]);
|
||||
}, [size.field, size.scale, JSON.stringify(size.values), JSON.stringify(size.options)]);
|
||||
return null;
|
||||
});
|
||||
|
|
|
@ -22,6 +22,9 @@ export interface IAttributeOptions {
|
|||
values: string[] | number[] | string | number | CallBack;
|
||||
scale?: string;
|
||||
blend: keyof typeof BlendType;
|
||||
options?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IScaleAttributeOptions {
|
||||
|
|
Loading…
Reference in New Issue