Debounced search input
TSXPublic
function SearchBox({ onSearch }: { onSearch: (q: string) => void }) {
const [value, setValue] = useState('')
const debounced = useDebounce(value, 250)
useEffect(() => {
onSearch(debounced)
}, [debounced, onSearch])
return (
<input
value={value}
onChange={(e) => setValue(e.target.value)}
placeholder="Search..."
/>
)
}Comments(0)
No comments yet. Start the conversation.