I\'m trying to use the throttle method from lodash in a functional component, e.g.:
const App = () => {
const [value, setValue
I'd like to join the party with my input debounce using useState:
// import { React, useState } from 'react' // nomral import
const { useState } = React // inline import
const App = () => {
const [t, setT] = useState();
const handleChange = ({ target: { value } }) => {
clearTimeout(t)
setT(setTimeout(() => console.log(value), 700))
}
return (
)
}
ReactDOM.render( , document.getElementById('root'))