UNPKG

@procore/core-react

Version:
44 lines (38 loc) 986 B
import React from 'react'; /* TYPES */ /** * @deprecatedSince 9 * @deprecated Never officially documented/supported */ /* HOOK */ /** * @deprecatedSince 9 * @deprecated Never officially documented/supported */ export function useTimer(config) { var timer = React.useRef(null); return { cancel: function cancel() { timer.current && clearTimeout(timer.current); }, reset: function reset() { timer.current && clearTimeout(timer.current); }, setTimer: function setTimer(callback, duration) { timer.current && clearTimeout(timer.current); timer.current = window.setTimeout(callback, duration); }, timerId: timer.current }; } /* RENDER PROP */ /** * @deprecatedSince 9 * @deprecated Never officially documented/supported */ export function Timer(_ref) { var children = _ref.children; var timer = useTimer({}); return typeof children === 'function' ? children(timer) : children; } //# sourceMappingURL=Timer.js.map