@@ -121,8 +121,6 @@ export interface TableProps<RecordType = unknown>
121
121
122
122
sticky ?: boolean | TableSticky ;
123
123
124
- reference ?: React . Ref < Reference > ;
125
-
126
124
// =================================== Internal ===================================
127
125
/**
128
126
* @private Internal usage, may remove by refactor. Should always use `columns` instead.
@@ -170,7 +168,10 @@ function defaultEmpty() {
170
168
return 'No Data' ;
171
169
}
172
170
173
- function Table < RecordType extends DefaultRecordType > ( tableProps : TableProps < RecordType > ) {
171
+ function Table < RecordType extends DefaultRecordType > (
172
+ tableProps : TableProps < RecordType > ,
173
+ ref : React . Ref < Reference > ,
174
+ ) {
174
175
const props = {
175
176
rowKey : 'key' ,
176
177
prefixCls : DEFAULT_PREFIX ,
@@ -188,7 +189,6 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco
188
189
scroll,
189
190
tableLayout,
190
191
direction,
191
- reference,
192
192
193
193
// Additional Part
194
194
title,
@@ -314,7 +314,7 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco
314
314
const scrollBodyRef = React . useRef < HTMLDivElement > ( ) ;
315
315
const scrollBodyContainerRef = React . useRef < HTMLDivElement > ( ) ;
316
316
317
- React . useImperativeHandle ( reference , ( ) => {
317
+ React . useImperativeHandle ( ref , ( ) => {
318
318
return {
319
319
nativeElement : fullTableRef . current ,
320
320
scrollTo : config => {
@@ -876,8 +876,20 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco
876
876
return < TableContext . Provider value = { TableContextValue } > { fullTable } </ TableContext . Provider > ;
877
877
}
878
878
879
- export function genTable ( shouldTriggerRender ?: CompareProps < typeof Table > ) : typeof Table {
880
- return makeImmutable ( Table , shouldTriggerRender ) ;
879
+ export type ForwardGenericTable = ( < RecordType extends DefaultRecordType = any > (
880
+ props : TableProps < RecordType > & { ref ?: React . Ref < Reference > } ,
881
+ ) => React . ReactElement ) & {
882
+ displayName ?: string ;
883
+ } ;
884
+
885
+ const RefTable = React . forwardRef ( Table ) as ForwardGenericTable ;
886
+
887
+ if ( process . env . NODE_ENV !== 'production' ) {
888
+ RefTable . displayName = 'Table' ;
889
+ }
890
+
891
+ export function genTable ( shouldTriggerRender ?: CompareProps < typeof Table > ) {
892
+ return makeImmutable ( RefTable , shouldTriggerRender ) as ForwardGenericTable ;
881
893
}
882
894
883
895
const ImmutableTable = genTable ( ) ;
0 commit comments