ant-design/components/select/demo/search.tsx
Isaac Batista 966e5a770f
demo: fix typescript undefined error on search.tsx (#45027)
Without this typescript will not compile

Signed-off-by: Isaac Batista <isaacbatst@gmail.com>
2023-09-25 12:18:20 +08:00

42 lines
857 B
TypeScript

import React from 'react';
import { Select } from 'antd';
const onChange = (value: string) => {
console.log(`selected ${value}`);
};
const onSearch = (value: string) => {
console.log('search:', value);
};
// Filter `option.label` match the user type `input`
const filterOption = (input: string, option?: { label: string; value: string }) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase());
const App: React.FC = () => (
<Select
showSearch
placeholder="Select a person"
optionFilterProp="children"
onChange={onChange}
onSearch={onSearch}
filterOption={filterOption}
options={[
{
value: 'jack',
label: 'Jack',
},
{
value: 'lucy',
label: 'Lucy',
},
{
value: 'tom',
label: 'Tom',
},
]}
/>
);
export default App;