UNPKG

phx-react

Version:

PHX REACT

14 lines 560 B
import { useState, useEffect } from 'react'; function PHXUseDebounce(value, delay) { var _a = useState(value), debounceValue = _a[0], setDebounceValue = _a[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; } export default PHXUseDebounce; //# sourceMappingURL=useDebounce.js.map