I have a Material UI Textfield that contains an onChange.
This onChange, takes the event and execute the function handleOnChange. With this current implementation, the function handleOnChange is executed every-time the event changes.
It it possible to use debounce to execute the function only after 2000ms directly on the event?
My textfield
<TextField
onChange={
event =>
handleOnChange(
event.target.value,
firstValue,
secondValue,
)
/>
My function
const handleOnChange = (value, firstValue, secondValue) => {
...do something..
}
I tried the following, but handleOnChange still fires at every event change, not after 2000ms.
<TextField
onChange={
event =>
_.debounce(handleOnChange(
event.target.value,
firstValue,
secondValue,
), 2000)
/>