File tree Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -570,11 +570,12 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco
570
570
if ( typeof colWidth === 'number' && ! Number . isNaN ( colWidth ) ) {
571
571
return colWidth ;
572
572
}
573
- warning (
574
- false ,
575
- 'When use `components.body` with render props. Each column should have a fixed `width` value.' ,
576
- ) ;
577
-
573
+ if ( props . columns . length > 0 ) {
574
+ warning (
575
+ false ,
576
+ 'When use `components.body` with render props. Each column should have a fixed `width` value.' ,
577
+ ) ;
578
+ }
578
579
return 0 ;
579
580
} ) as number [ ] ;
580
581
} else {
@@ -599,7 +600,11 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco
599
600
{ bodyColGroup }
600
601
{ bodyTable }
601
602
{ ! fixFooter && summaryNode && (
602
- < Footer stickyOffsets = { stickyOffsets } flattenColumns = { flattenColumns } columns = { columns } >
603
+ < Footer
604
+ stickyOffsets = { stickyOffsets }
605
+ flattenColumns = { flattenColumns }
606
+ columns = { columns }
607
+ >
603
608
{ summaryNode }
604
609
</ Footer >
605
610
) }
Original file line number Diff line number Diff line change @@ -701,6 +701,24 @@ describe('Table.Basic', () => {
701
701
} ) ;
702
702
} ) ;
703
703
704
+ it ( 'without warning - columns is emplty' , ( ) => {
705
+ resetWarned ( ) ;
706
+ const errSpy = jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
707
+ mount (
708
+ createTable ( {
709
+ columns : [ ] ,
710
+ components : {
711
+ body : ( ) => < h1 > Bamboo</ h1 > ,
712
+ } ,
713
+ scroll : { x : 100 , y : 100 } ,
714
+ } ) ,
715
+ ) ;
716
+ expect ( errSpy ) . not . toHaveBeenCalledWith (
717
+ 'Warning: When use `components.body` with render props. Each column should have a fixed `width` value.' ,
718
+ ) ;
719
+ errSpy . mockRestore ( ) ;
720
+ } ) ;
721
+
704
722
it ( 'not crash' , ( ) => {
705
723
const Looper = React . forwardRef ( ( ) => < td /> ) ;
706
724
Looper . looper = Looper ;
You can’t perform that action at this time.
0 commit comments