React debouncing pattern for API calls Classic debounce function: const debounce = (fn, delay) => { let timer = null; return function (...args) { const context = this; timer && clearTimeout(timer); timer = setTimeout(() => {