mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 16:06:28 +08:00
udpate warning (#16138)
This commit is contained in:
parent
fdcfabfa78
commit
21c0ba5bbd
@ -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.',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user