"use client"; import { FC, useEffect, useState } from "react"; import { IoSearch } from "react-icons/io5"; type Props = { className?: string; defaultValue?: string; placeholder?: string; onChange?: (value: string) => void; debounce?: number; autoFocus?: boolean; }; export const SearchInput: FC = ({ className = "", defaultValue = "", placeholder = "Search", onChange, debounce = 500, autoFocus = false, }) => { const [value, setValue] = useState(defaultValue); useEffect(() => { const timer = setTimeout(() => { onChange?.(value ?? ""); }, debounce); return () => clearTimeout(timer); }, [value]); return (
setValue(e.target.value)} autoFocus={autoFocus} />
); };