Skip to content

Instantly share code, notes, and snippets.

@unigazer
Created February 7, 2021 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unigazer/a5dfc66cab437fafb75d1c276718eeb7 to your computer and use it in GitHub Desktop.
Save unigazer/a5dfc66cab437fafb75d1c276718eeb7 to your computer and use it in GitHub Desktop.
Debounce function for remote search using React Hooks
// Credits: https://stackoverflow.com/a/61629055/5981004
useEffect(() => {
const delayDebounceFn = setTimeout(() => {
// HTTP
}, 500)
return () => clearTimeout(delayDebounceFn)
}, [input])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment