import React, { useEffect, useState } from 'react'; import { Switch, Transfer } from 'antd'; import type { TransferDirection } from 'antd/es/transfer'; interface RecordType { key: string; title: string; description: string; chosen: boolean; } const App: React.FC = () => { const [oneWay, setOneWay] = useState(false); const [mockData, setMockData] = useState([]); const [targetKeys, setTargetKeys] = useState([]); useEffect(() => { const newTargetKeys = []; const newMockData = []; for (let i = 0; i < 2000; i++) { const data = { key: i.toString(), title: `content${i + 1}`, description: `description of content${i + 1}`, chosen: i % 2 === 0, }; if (data.chosen) { newTargetKeys.push(data.key); } newMockData.push(data); } setTargetKeys(newTargetKeys); setMockData(newMockData); }, []); const onChange = (newTargetKeys: string[], direction: TransferDirection, moveKeys: string[]) => { console.log(newTargetKeys, direction, moveKeys); setTargetKeys(newTargetKeys); }; return ( <> item.title} oneWay={oneWay} pagination />
); }; export default App;