import React, { useState, useRef } from 'react'; import { PlusOutlined } from '@ant-design/icons'; import { Divider, Input, Select, Space, Button } from 'antd'; import type { InputRef } from 'antd'; let index = 0; const App: React.FC = () => { const [items, setItems] = useState(['jack', 'lucy']); const [name, setName] = useState(''); const inputRef = useRef(null); const onNameChange = (event: React.ChangeEvent) => { setName(event.target.value); }; const addItem = (e: React.MouseEvent) => { e.preventDefault(); setItems([...items, name || `New item ${index++}`]); setName(''); setTimeout(() => { inputRef.current?.focus(); }, 0); }; return ( )} options={items.map(item => ({ label: item, value: item }))} /> ); }; export default App;