1- import { type ChangeEvent } from "react" ;
2- import { type UseFormSetValue , type UseFormRegister } from "react-hook-form" ;
1+ import { type UseFormRegister } from "react-hook-form" ;
32import { SearchIcon , CancelIcon } from "@ui/public" ;
4- import { useDebouncedCallback } from "@/app/_hooks/useDebounceCallback" ;
53
64interface KeywordsFormData {
75 keyword : string ;
86 searchHistory : string [ ] ;
97}
108interface 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" >
0 commit comments