57
rated 0 times
[
64]
[
7]
/ answers: 1 / hits: 6883
/ 4 Years ago, mon, august 31, 2020, 12:00:00
I'm trying to debounce text input field change with Lodash's debounce
function.
import React from "react";
import debounce from 'lodash.debounce';
const Input = () => {
const onChange = debounce((e) => {
const { value } = e.target;
console.log('debounced value', value)
}, 1000)
return (
<input type="text" onChange={ onChange } />
)
};
The code above throws the following errors:
Warning: This synthetic event is reused for performance reasons. If you're seeing this, you're accessing the property target on a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around, use event.persist().
Uncaught TypeError: Cannot read property 'value' of null
What is the correct implementation?
More From » reactjs