UNPKG

@preact-hooks/instance

Version:

A custom Preact Hook that provides a sensible alternative to useRef for storing instance variables.

2 lines (1 loc) 366 B
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("preact/hooks")):"function"==typeof define&&define.amd?define(["preact/hooks"],n):(e=e||self).useInstance=n(e.preactHooks)}(this,(function(e){return function(n){void 0===n&&(n={});var t=e.useRef(null);return t.current||(t.current="function"==typeof n?n():n),t.current}}));