UNPKG

@react-hookbox/enhanced-callback

Version:

The enhanced version of useCallback that doesn't need deps array and keeps reference the same.

19 lines (16 loc) 735 B
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) : typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) : (global = global || self, factory(global.enhancedCallback = {}, global.react)); }(this, (function (exports, react) { var useEnhancedCallback = function useEnhancedCallback(fn) { var callbackRef = react.useRef(fn); callbackRef.current = fn; return react.useCallback(function () { return callbackRef.current.apply(callbackRef, arguments); }, []); }; exports.default = useEnhancedCallback; exports.useEnhancedCallback = useEnhancedCallback; }))); //# sourceMappingURL=index.umd.js.map