-
-
Save a2ankitrai/a9404228da6f25bc5d7a678148683af3 to your computer and use it in GitHub Desktop.
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
| function useDebounced(value, timeout) { | |
| let [debouncedValue, setDebouncedValue] = useState(value) | |
| useEffect(() => { | |
| let timeoutId = setTimeout(() => { | |
| setDebouncedValue(value) | |
| }, timeout) | |
| return () => { | |
| clearTimeout(timeoutId) | |
| } | |
| }, [value, timeout]) | |
| return debouncedValue | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment