diff --git a/components/table/InternalTable.tsx b/components/table/InternalTable.tsx index 15890f3efa..4e97ad8bb1 100644 --- a/components/table/InternalTable.tsx +++ b/components/table/InternalTable.tsx @@ -400,17 +400,20 @@ function InternalTable( ]); // ========================== Selections ========================== - const [transformSelectionColumns, selectedKeySet] = useSelection(rowSelection, { - prefixCls, - data: mergedData, - pageData, - getRowKey, - getRecordByKey, - expandType, - childrenColumnName, - locale: tableLocale, - getPopupContainer: getPopupContainer || getContextPopupContainer, - }); + const [transformSelectionColumns, selectedKeySet] = useSelection( + { + prefixCls, + data: mergedData, + pageData, + getRowKey, + getRecordByKey, + expandType, + childrenColumnName, + locale: tableLocale, + getPopupContainer: getPopupContainer || getContextPopupContainer, + }, + rowSelection, + ); const internalRowClassName = (record: RecordType, index: number, indent: number) => { let mergedRowClassName: string; diff --git a/components/table/hooks/useSelection.tsx b/components/table/hooks/useSelection.tsx index 55d7be0d5c..6166f2bc53 100644 --- a/components/table/hooks/useSelection.tsx +++ b/components/table/hooks/useSelection.tsx @@ -68,10 +68,10 @@ function flattenData(childrenColumnName: string, data?: RecordType[] return list; } -export default function useSelection( - rowSelection: TableRowSelection | undefined, +function useSelection( config: UseSelectionConfig, -): [TransformColumns, Set] { + rowSelection?: TableRowSelection, +): readonly [TransformColumns, Set] { const { preserveSelectedRowKeys, selectedRowKeys, @@ -716,5 +716,7 @@ export default function useSelection( ], ); - return [transformColumns, derivedSelectedKeySet]; + return [transformColumns, derivedSelectedKeySet] as const; } + +export default useSelection;