mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 16:06:28 +08:00
demo: improve Select demo (#41986)
Co-authored-by: songzihao <zihao.szh@digital-engine.com>
This commit is contained in:
parent
4d0f399f0b
commit
ab5ebb0278
@ -32,8 +32,11 @@ const fetch = (value: string, callback: Function) => {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
timeout = setTimeout(fake, 300);
|
||||
if (value) {
|
||||
timeout = setTimeout(fake, 300);
|
||||
} else {
|
||||
callback([]);
|
||||
}
|
||||
};
|
||||
|
||||
const SearchInput: React.FC<{ placeholder: string; style: React.CSSProperties }> = (props) => {
|
||||
@ -41,11 +44,7 @@ const SearchInput: React.FC<{ placeholder: string; style: React.CSSProperties }>
|
||||
const [value, setValue] = useState<string>();
|
||||
|
||||
const handleSearch = (newValue: string) => {
|
||||
if (newValue) {
|
||||
fetch(newValue, setData);
|
||||
} else {
|
||||
setData([]);
|
||||
}
|
||||
fetch(newValue, setData);
|
||||
};
|
||||
|
||||
const handleChange = (newValue: string) => {
|
||||
|
Loading…
Reference in New Issue
Block a user