zombieJ
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
12 additions and
8 deletions
-
components/table/Table.tsx
-
components/table/__tests__/Table.test.js
|
|
@ -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); |
|
|
|
|
|
|
|
|
|
@ -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.', |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|