react debounce lodash code example
Example 1: onchange debounce react
import React, { useCallback } from 'react';
import _ from 'lodash';
const MyComponent = ({ data, handleInputChange }) => {
const debounceFunc = useCallback(
_.debounce(e => handleInputChange(e), 500),
[]
);
const handleChange = e => {
debounceFunc(e);
};
return <TextInput data={data} onChange={handleChange} />;
};
export default MyComponent;
Example 2: lodash debounce
_.debounce(func, [wait=0], [options={}])