//debounce with react js
// import useState hook
const [productName, setProductName] = useState("");
//write debounce function
let timeOutId;
const handleSearch = (value)=>{
if(timeOutId){clearTimeout(timeOutId)}
timeOutId = setTimeout(() => {setProductName(value)},500)
}
//ui
<input type="text" onChange={(e) => handleSearch(e.target.value)} />