Last active
March 4, 2024 04:48
-
-
Save christianvmm/dba7ad4db2108d149aa44d9c89cf8704 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
| export const debounce = (func) => { | |
| let timer; | |
| return function(...args) { | |
| const context = this; | |
| if(timer) clearTimeout(timer); | |
| timer = setTimeout(() => { | |
| timer = null; | |
| func.apply(context, args); | |
| }, 500); | |
| } | |
| } | |
| // Ejemplo de uso | |
| const optimizedSearch = useCallback(debounce(searchFunction), []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment