@zendesk/react-measure-timing-hooks
Version:
react hooks for measuring time to interactive and time to render of components
23 lines • 990 B
JavaScript
/**
* Copyright Zendesk, Inc.
*
* Use of this source code is governed under the Apache License, Version 2.0
* found at http://www.apache.org/licenses/LICENSE-2.0.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.useActionLog = void 0;
const react_1 = require("react");
const useActionLog = ({ id, actionLogCache, garbageCollectMs, ...actionLogOptions }) => {
// reuse ActionLog of the same ID:
const getCurrentActionLog = (0, react_1.useMemo)(() => actionLogCache.makeGetOrCreateFn(id),
// we do not want to change the instance when the ID or options change,
// rather, we do the opposite - we update the cache to also reflect the new ID below
// hence this eslint rule is silenced on purpose
[]);
const currentActionLog = getCurrentActionLog(id);
currentActionLog.updateStaticOptions(actionLogOptions);
return currentActionLog;
};
exports.useActionLog = useActionLog;
//# sourceMappingURL=useActionLog.js.map
;