I\'m trying to add debouncing with lodash to a search function, called from an input onChange event. The code below generates a type error \'function is expected\', which I unde
@Aximili
const [debouncedCallApi] = useState(() => _.debounce(callApi, 1000));
looks strange :) I prefare solutions with useCallback:
useCallback
const [searchFor, setSearchFor] = useState(''); const changeSearchFor = debounce(setSearchFor, 1000); const handleChange = useCallback(changeSearchFor, []);