phx-react
Version:
PHX REACT
16 lines • 620 B
JavaScript
;
exports.__esModule = true;
var react_1 = require("react");
function PHXUseDebounce(value, delay) {
var _a = (0, react_1.useState)(value), debounceValue = _a[0], setDebounceValue = _a[1];
(0, react_1.useEffect)(function () {
var handler = setTimeout(function () {
setDebounceValue(value);
}, delay);
return function () { return clearTimeout(handler); };
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [value]); // delay ko thay đổi
return debounceValue;
}
exports["default"] = PHXUseDebounce;
//# sourceMappingURL=useDebounce.js.map