import React, { useState } from 'react'; import { Button, Flex, Table } from 'antd'; import type { TableColumnsType } from 'antd'; import type { TableRowSelection } from 'antd/es/table/interface'; interface DataType { key: React.Key; name: string; age: number; address: string; } const columns: TableColumnsType = [ { title: 'Name', dataIndex: 'name' }, { title: 'Age', dataIndex: 'age' }, { title: 'Address', dataIndex: 'address' }, ]; const dataSource = Array.from({ length: 46 }).map((_, i) => ({ key: i, name: `Edward King ${i}`, age: 32, address: `London, Park Lane no. ${i}`, })); const App: React.FC = () => { const [selectedRowKeys, setSelectedRowKeys] = useState([]); const [loading, setLoading] = useState(false); const start = () => { setLoading(true); // ajax request after empty completing setTimeout(() => { setSelectedRowKeys([]); setLoading(false); }, 1000); }; const onSelectChange = (newSelectedRowKeys: React.Key[]) => { console.log('selectedRowKeys changed: ', newSelectedRowKeys); setSelectedRowKeys(newSelectedRowKeys); }; const rowSelection: TableRowSelection = { selectedRowKeys, onChange: onSelectChange, }; const hasSelected = selectedRowKeys.length > 0; return ( {hasSelected ? `Selected ${selectedRowKeys.length} items` : null} ); }; export default App;