UNPKG

rooks

Version:

Essential React custom hooks ⚓ to super charge your components!

25 lines (24 loc) 738 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useFreshTick = void 0; var useFreshRef_1 = require("./useFreshRef"); /** * useFreshTick * @param callback The callback to be called on mount * @returns A fresh callback. * @see https://react-hooks.org/docs/useFreshCallback */ function useFreshTick(callback) { var freshRef = (0, useFreshRef_1.useFreshRef)(callback); function tick() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } if (typeof freshRef.current === "function") { freshRef.current.apply(freshRef, args); } } return tick; } exports.useFreshTick = useFreshTick;