Skip to content

Instantly share code, notes, and snippets.

@namcoder
Created July 18, 2019 16:54
Show Gist options
  • Save namcoder/e53f48ce5670871a3a2aa4402a0fca43 to your computer and use it in GitHub Desktop.
Save namcoder/e53f48ce5670871a3a2aa4402a0fca43 to your computer and use it in GitHub Desktop.
React trick: Waiting for user stop typing then beign search. Does not take search for every key, save performance
searchPost = value =>{
clearTimeout(this.timeout)
this.timeout = setTimeout(() => {
if(value.length < 1) return
return console.log('begin search: ', value)
}, 500)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment