mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
修复 crud 列切换和拖拽不渲染的问题
This commit is contained in:
parent
cedcc9e62b
commit
bf6db5feab
@ -53,6 +53,7 @@ export class TableContent extends React.Component<TableContentProps> {
|
||||
super(props);
|
||||
|
||||
const rows = props.rows;
|
||||
|
||||
this.reaction = reaction(
|
||||
() => `${rows.map(item => item.id).join(',')}`,
|
||||
() => this.forceUpdate(),
|
||||
@ -62,7 +63,13 @@ export class TableContent extends React.Component<TableContentProps> {
|
||||
);
|
||||
}
|
||||
|
||||
shouldComponentUpdate() {
|
||||
shouldComponentUpdate(nextProps: TableContentProps) {
|
||||
const props = this.props;
|
||||
|
||||
if (props.columns !== nextProps.columns) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -34,11 +34,12 @@ export class TableRow extends React.Component<TableRowProps> {
|
||||
|
||||
const item = props.item;
|
||||
const parent = props.parent;
|
||||
const columns = props.columns;
|
||||
this.reaction = reaction(
|
||||
() =>
|
||||
`${item.isHover}${item.checked}${JSON.stringify(item.data)}${
|
||||
item.moved
|
||||
}${item.modified}${item.expanded}${parent?.expanded}`,
|
||||
}${item.modified}${item.expanded}${parent?.expanded}${columns.length}`,
|
||||
() => this.forceUpdate(),
|
||||
{
|
||||
onError: () => this.reaction!()
|
||||
@ -46,7 +47,12 @@ export class TableRow extends React.Component<TableRowProps> {
|
||||
);
|
||||
}
|
||||
|
||||
shouldComponentUpdate() {
|
||||
shouldComponentUpdate(nextProps: TableRowProps) {
|
||||
const props = this.props;
|
||||
if (props.columns !== nextProps.columns) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 不需要更新,因为孩子节点已经 observer 了
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user