|  |  | 
 |  |  |                 }))) | 
 |  |  |             } else { | 
 |  |  |                 console.error(msg); | 
 |  |  |                 setOptions([]); | 
 |  |  |             } | 
 |  |  |         } catch (error) { | 
 |  |  |             console.error(error.message); | 
 |  |  | 
 |  |  |     const debouncedFetch = useCallback(debounce(fetchData, 300), [url]); | 
 |  |  |  | 
 |  |  |     useEffect(() => { | 
 |  |  |         if (inputValue) { | 
 |  |  |             debouncedFetch(inputValue); | 
 |  |  |         } else { | 
 |  |  |             setOptions([]); | 
 |  |  |         } | 
 |  |  |         // console.log(inputValue, url) | 
 |  |  |         // if (inputValue) { | 
 |  |  |         //     debouncedFetch(inputValue); | 
 |  |  |         // } else { | 
 |  |  |         //     setOptions([]); | 
 |  |  |         // } | 
 |  |  |         debouncedFetch(inputValue); | 
 |  |  |     }, [inputValue, debouncedFetch]); | 
 |  |  |  | 
 |  |  |     const resetInput = () => setInputValue(''); | 
 |  |  |  | 
 |  |  |     return { | 
 |  |  |         options, | 
 |  |  |         setInputValue, | 
 |  |  |         resetInput, | 
 |  |  |     }; | 
 |  |  | } | 
 |  |  |  |