import React from "react";
import { render } from "react-dom";
const debounce = (func, delay) => {
let timer;
return (...args) => {
clearTimeout(timer);
timer = setTimeout(() => {
func(...args);
}, delay);
};
};
const printData = (data) => {
console.log("data", data);
};
// const getData = debounce((input) => printData(input), 5000);
// OR
const getData = debounce(printData, 5000);
const App = (props) => {
return (
<div>
<h2>Debounce Example List</h2>
<input type="text" onChange={(event) => getData(event.target.value)} />
</div>
);
};
render(<App />, document.getElementById("root"));
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)