import React, { useState } from 'react'; import { AutoComplete, Input } from 'antd'; import type { SelectProps } from 'antd/es/select'; const getRandomInt = (max: number, min = 0) => Math.floor(Math.random() * (max - min + 1)) + min; const searchResult = (query: string) => new Array(getRandomInt(5)) .join('.') .split('.') .map((_, idx) => { const category = `${query}${idx}`; return { value: category, label: (
Found {query} on{' '} {category} {getRandomInt(200, 100)} results
), }; }); const App: React.FC = () => { const [options, setOptions] = useState['options']>([]); const handleSearch = (value: string) => { setOptions(value ? searchResult(value) : []); }; const onSelect = (value: string) => { console.log('onSelect', value); }; return ( ); }; export default App;