Browse Source

udpate warning (#16138)

pull/16142/head
zombieJ 6 years ago
committed by GitHub
parent
commit
21c0ba5bbd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      components/table/Table.tsx
  2. 6
      components/table/__tests__/Table.test.js

14
components/table/Table.tsx

@ -110,6 +110,8 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
constructor(props: TableProps<T>) {
super(props);
const { expandedRowRender, columns = [] } = props;
warning(
!('columnsPageRange' in props || 'columnsPageSize' in props),
'Table',
@ -117,11 +119,13 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
'fixed columns instead, see: https://u.ant.design/fixed-columns.',
);
warning(
!('expandedRowRender' in props) || !('scroll' in props),
'Table',
'`expandedRowRender` and `scroll` are not compatible. Please use one of them at one time.',
);
if (expandedRowRender && columns.some(({ fixed }) => !!fixed)) {
warning(
false,
'Table',
'`expandedRowRender` and `Column.fixed` are not compatible. Please use one of them at one time.',
);
}
this.columns = props.columns || normalizeColumns(props.children as React.ReactChildren);

6
components/table/__tests__/Table.test.js

@ -87,10 +87,10 @@ describe('Table', () => {
expect(wrapper.find('tbody').props().id).toBe('wrapper2');
});
it('warning if both `expandedRowRender` & `scroll` are used', () => {
mount(<Table expandedRowRender={() => null} scroll={{}} />);
it('warning if both `expandedRowRender` & `Column.fixed` are used', () => {
mount(<Table expandedRowRender={() => null} columns={[{ fixed: true }]} />);
expect(warnSpy).toHaveBeenCalledWith(
'Warning: [antd: Table] `expandedRowRender` and `scroll` are not compatible. Please use one of them at one time.',
'Warning: [antd: Table] `expandedRowRender` and `Column.fixed` are not compatible. Please use one of them at one time.',
);
});
});

Loading…
Cancel
Save