Created
July 18, 2019 16:54
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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