UNPKG

@rooks/use-isomorphic-effect

Version:

Resolves to useEffect when window is not in scope and useLayout effect in the browser

18 lines (14 loc) 761 B
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) : typeof define === 'function' && define.amd ? define(['react'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.useIsomorphicEffect = factory(global.React)); }(this, (function (react) { 'use strict'; /** * useIsomorphicEffect * Resolves to useEffect when "window" is not in scope and useLayout effect in the browser * @param {function} callback Callback function to be called on mount */ const useIsomorphicEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect; return useIsomorphicEffect; }))); //# sourceMappingURL=index.js.map