mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-05 05:18:34 +08:00
fix: 优化 inputTable state 更新逻辑,减少多余重新渲染 (#10464)
This commit is contained in:
parent
e6f2b5146a
commit
9d4c34be69
@ -369,7 +369,7 @@ export default class FormTable extends React.Component<TableProps, TableState> {
|
||||
};
|
||||
}
|
||||
|
||||
if (props.value !== prevProps.value) {
|
||||
if (props.value !== prevProps.value && props.value !== this.emittedValue) {
|
||||
toUpdate = {
|
||||
...toUpdate,
|
||||
items: Array.isArray(props.value) ? props.value.concat() : [],
|
||||
@ -494,12 +494,17 @@ export default class FormTable extends React.Component<TableProps, TableState> {
|
||||
return msg;
|
||||
}
|
||||
|
||||
emittedValue: any = null;
|
||||
async emitValue(value?: any[]) {
|
||||
const items =
|
||||
value ?? this.state.items.filter(item => !item.__isPlaceholder);
|
||||
const {onChange} = this.props;
|
||||
const isPrevented = await this.dispatchEvent('change');
|
||||
isPrevented || onChange?.(items);
|
||||
if (!isPrevented) {
|
||||
this.emittedValue = items;
|
||||
onChange?.(items);
|
||||
}
|
||||
|
||||
return isPrevented;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user