mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 22:36:31 +08:00
🐛 Fix Table inifinite loop issue
This commit is contained in:
parent
715814291b
commit
0bdf682a80
@ -284,7 +284,7 @@ class Table<T> extends React.Component<InternalTableProps<T>, TableState<T>> {
|
||||
const { columns, sortColumn, sortOrder } = this.state;
|
||||
if (this.getSortOrderColumns(columns).length > 0) {
|
||||
const sortState = this.getSortStateFromColumns(columns);
|
||||
if (sortState.sortColumn !== sortColumn || sortState.sortOrder !== sortOrder) {
|
||||
if (!isSameColumn(sortState.sortColumn, sortColumn) || sortState.sortOrder !== sortOrder) {
|
||||
this.setState(sortState);
|
||||
}
|
||||
}
|
||||
|
@ -676,4 +676,24 @@ describe('Table.sorter', () => {
|
||||
|
||||
expect(renderedNames(wrapper)).toEqual(['Brown', 'Green', 'Mike', 'Alex', 'Petter', 'Zoe']);
|
||||
});
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/19443
|
||||
it('should not being inifinite loop when using Table.Column with sortOrder', () => {
|
||||
class Demo extends React.Component {
|
||||
componentDidMount() {
|
||||
this.setState({});
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Table dataSource={[]}>
|
||||
<Table.Column title="Age" dataIndex="age" sorter sortOrder="ascend" key="age" />
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
}
|
||||
expect(() => {
|
||||
mount(<Demo />);
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user