Skip to content

Commit 6af0ce7

Browse files
authored
[Refactor] 멤버 관리 페이지 Search Input 디바운스 로직 제거 (#206)
Refactor: 디바운스 로직 제거
1 parent db537a2 commit 6af0ce7

2 files changed

Lines changed: 4 additions & 24 deletions

File tree

apps/web/app/(admin)/members/_components/search/SearchInput.tsx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
1-
import { type ChangeEvent } from "react";
2-
import { type UseFormSetValue, type UseFormRegister } from "react-hook-form";
1+
import { type UseFormRegister } from "react-hook-form";
32
import { SearchIcon, CancelIcon } from "@ui/public";
4-
import { useDebouncedCallback } from "@/app/_hooks/useDebounceCallback";
53

64
interface KeywordsFormData {
75
keyword: string;
86
searchHistory: string[];
97
}
108
interface SearchInputProps {
119
register: UseFormRegister<KeywordsFormData>;
12-
setValue: UseFormSetValue<KeywordsFormData>;
1310
keyword: string;
1411
onFocus: () => void;
1512
onClear: () => void;
1613
}
1714

18-
export default function SearchInput({ register, setValue, keyword, onFocus, onClear }: SearchInputProps): JSX.Element {
19-
const debouncedSetValue = useDebouncedCallback((value: string) => {
20-
setValue("keyword", value);
21-
}, 300);
22-
23-
const handleInputChange = (e: ChangeEvent<HTMLInputElement>): void => {
24-
const value = e.target.value;
25-
debouncedSetValue(value);
26-
};
27-
15+
export default function SearchInput({ register, keyword, onFocus, onClear }: SearchInputProps): JSX.Element {
2816
return (
2917
<>
3018
<label htmlFor="keyword">
@@ -34,9 +22,7 @@ export default function SearchInput({ register, setValue, keyword, onFocus, onCl
3422
id="keyword"
3523
className="h-18 w-full bg-transparent focus:outline-none"
3624
onFocus={onFocus}
37-
{...register("keyword", {
38-
onChange: handleInputChange,
39-
})}
25+
{...register("keyword")}
4026
/>
4127
{keyword ? (
4228
<button type="button" onClick={onClear} className="flex items-center justify-center">

apps/web/app/(admin)/members/_components/search/index.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,7 @@ export default function SearchForm({ onSearch, keyword }: SearchFormProps): JSX.
8585
onSubmit={(...args) => void handleSubmit(onSubmit)(...args)}
8686
className="rounded-100 border-1 focus-within:border-custom-black/20 group flex h-full w-full items-center gap-14 border-gray-100/30 bg-gray-100/30 px-20 transition-all duration-200 focus-within:bg-white hover:bg-gray-100/45 focus-within:hover:bg-white"
8787
>
88-
<SearchInput
89-
register={register}
90-
setValue={setValue}
91-
keyword={keyword}
92-
onFocus={handleOpenHistory}
93-
onClear={handleClearInput}
94-
/>
88+
<SearchInput register={register} keyword={keyword} onFocus={handleOpenHistory} onClear={handleClearInput} />
9589
</form>
9690

9791
{isHistoryOpen ? (

0 commit comments

Comments
 (0)