react-singleton-hook
Advanced tools
Comparing version 1.0.9 to 1.0.12
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom'], factory) : | ||
(global = global || self, factory(global.ReactRedux = {}, global.React, global.ReactDOM)); | ||
(global = global || self, factory(global.ReactSingletonHook = {}, global.React, global.ReactDOM)); | ||
}(this, (function (exports, React, reactDom) { 'use strict'; | ||
@@ -6,0 +6,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],n):n((e=e||self).ReactRedux={},e.React,e.ReactDOM)}(this,(function(e,n,t){"use strict";var o="default"in n?n.default:n;function r(){return(r=Object.assign||function(e){for(var n=1;arguments.length>n;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e}).apply(this,arguments)}var u=function(e){var t=e.useHookBody,o=e.applyStateChange,r=n.useRef(e.initValue);if("function"!=typeof t)throw Error("function expected as hook body parameter. got "+typeof t);var u=t();return n.useLayoutEffect((function(){r.current!==u&&(r.current=u,o(u))}),[o,u]),null},i=function(e){console&&console.warn&&console.warn(e)},a=!1,c=!1,f=!1,l=[],s=function(e){l.push(e)},d=function(){c=!0,n.useEffect((function(){return a&&i("SingletonContainer is mounted second time. You should mount SingletonContainer before any other component and never unmount it.Alternatively, dont use SingletonContainer it at all, we will handle that for you."),a=!0,function(){return i("SingletonContainer is removed from DOM. its not supported, singleton hooks will stop updating.")}}),[]);var e=n.useState([]),t=e[0],f=e[1];return n.useEffect((function(){s=function(e){return f((function(n){return[].concat(n,[e])}))},f(l)}),[]),o.createElement(o.Fragment,null,t.map((function(e,n){return o.createElement(u,r({},e,{key:n}))})))},p=function(e){var n;c||f||(f=!0,n=d,window&&window.document?t.render(o.createElement(n,null),window.document.createElement("div")):i("Can not mount SingletonContainer on server side. Did you manage to run useEffect on server? Please mount SingletonContainer into your components tree manually.")),s(e)};e.SingletonContainer=d,e.singletonHook=function(e,o){var r=!1,u=e,i=[],a=function(e){u=e,t.unstable_batchedUpdates((function(){return i.forEach((function(n){return n(e)}))}))};return function(){var t=n.useState(u),c=t[0],f=t[1];return r||(r=!0,p({initValue:e,useHookBody:o,applyStateChange:a})),n.useEffect((function(){return i.push(f),u!==c&&f(u),function(){i.splice(i.indexOf(f),1)}}),[]),c}},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],e):e((n=n||self).ReactSingletonHook={},n.React,n.ReactDOM)}(this,(function(n,e,t){"use strict";var o="default"in e?e.default:e;function r(){return(r=Object.assign||function(n){for(var e=1;arguments.length>e;e++){var t=arguments[e];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o])}return n}).apply(this,arguments)}var u=function(n){var t=n.useHookBody,o=n.applyStateChange,r=e.useRef(n.initValue);if("function"!=typeof t)throw Error("function expected as hook body parameter. got "+typeof t);var u=t();return e.useLayoutEffect((function(){r.current!==u&&(r.current=u,o(u))}),[o,u]),null},i=function(n){console&&console.warn&&console.warn(n)},a=!1,c=!1,f=!1,l=[],s=function(n){l.push(n)},d=function(){c=!0,e.useEffect((function(){return a&&i("SingletonContainer is mounted second time. You should mount SingletonContainer before any other component and never unmount it.Alternatively, dont use SingletonContainer it at all, we will handle that for you."),a=!0,function(){return i("SingletonContainer is removed from DOM. its not supported, singleton hooks will stop updating.")}}),[]);var n=e.useState([]),t=n[0],f=n[1];return e.useEffect((function(){s=function(n){return f((function(e){return[].concat(e,[n])}))},f(l)}),[]),o.createElement(o.Fragment,null,t.map((function(n,e){return o.createElement(u,r({},n,{key:e}))})))},p=function(n){var e;c||f||(f=!0,e=d,window&&window.document?t.render(o.createElement(e,null),window.document.createElement("div")):i("Can not mount SingletonContainer on server side. Did you manage to run useEffect on server? Please mount SingletonContainer into your components tree manually.")),s(n)};n.SingletonContainer=d,n.singletonHook=function(n,o){var r=!1,u=n,i=[],a=function(n){u=n,t.unstable_batchedUpdates((function(){return i.forEach((function(e){return e(n)}))}))};return function(){var t=e.useState(u),c=t[0],f=t[1];return r||(r=!0,p({initValue:n,useHookBody:o,applyStateChange:a})),e.useEffect((function(){return i.push(f),u!==c&&f(u),function(){i.splice(i.indexOf(f),1)}}),[]),c}},Object.defineProperty(n,"__esModule",{value:!0})})); |
{ | ||
"name": "react-singleton-hook", | ||
"version": "1.0.9", | ||
"version": "1.0.12", | ||
"description": "Share custom hook state across all components", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29482