From da7ccda311e7238890f516a396d683f69f5e530a Mon Sep 17 00:00:00 2001 From: Vadzim Antonau Date: Sun, 13 Aug 2023 11:05:10 +0300 Subject: [PATCH] refactor: move debounce to handleSearch initialization --- client/src/components/UserSearch.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/components/UserSearch.tsx b/client/src/components/UserSearch.tsx index 94ca3d8da1..1f62455ccf 100644 --- a/client/src/components/UserSearch.tsx +++ b/client/src/components/UserSearch.tsx @@ -30,7 +30,7 @@ export function UserSearch(props: UserProps) { setData(defaultValues ?? []); }, [props.defaultValues]); - const handleSearch = async (value: string) => { + const handleSearch = debounce(async (value: string) => { value = value.trim(); if (value) { const data = await searchFn(value, onlyStudentsWithoutMentorShown); @@ -38,7 +38,7 @@ export function UserSearch(props: UserProps) { } else { setData(props.defaultValues ?? []); } - }; + }, 300); return (