Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-singleton-hook

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-singleton-hook - npm Package Compare versions

Comparing version 3.2.0 to 3.2.1

3

dist/react-singleton-hook.js

@@ -88,5 +88,2 @@ (function (global, factory) {

SingletonHooksContainerMounted = true;
return function () {
return warning('SingletonHooksContainer is removed from DOM. its not supported, singleton hooks will stop updating.');
};
}, []);

@@ -93,0 +90,0 @@

2

dist/react-singleton-hook.min.js

@@ -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="undefined"!=typeof globalThis?globalThis:e||self).ReactSingletonHook={},e.React,e.ReactDOM)}(this,(function(e,n,t){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=o(n);function u(){return(u=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 a=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)},l="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||this,f=!1,c=!1,s=!1,d=[],p=function(e){d.push(e)},g=function(){c=!0,n.useEffect((function(){return f&&i("SingletonHooksContainer is mounted second time. You should mount SingletonHooksContainer before any other component and never unmount it.Alternatively, dont use SingletonHooksContainer it at all, we will handle that for you."),f=!0,function(){return i("SingletonHooksContainer is removed from DOM. its not supported, singleton hooks will stop updating.")}}),[]);var e=n.useState([]),t=e[0],o=e[1];return n.useEffect((function(){p=function(e){return o((function(n){return[].concat(n,[e])}))},o(d)}),[]),r.default.createElement(r.default.Fragment,null,t.map((function(e,n){return r.default.createElement(a,u({},e,{key:n}))})))},m=function(e){var n;c||s||(s=!0,n=g,l.document&&l.document.createElement?t.render(r.default.createElement(n,null),l.document.createElement("div")):i("Can not mount SingletonHooksContainer on server side. Did you manage to run useEffect on server? Please mount SingletonHooksContainer into your components tree manually.")),p(e)},y=function(e,o){var r=!1,u=!1,a=void 0,i=[],l=function(e){a=e,t.unstable_batchedUpdates((function(){return i.forEach((function(n){return n(e)}))}))},f=function(){return u||(a="function"==typeof e?e():e,u=!0),a};return function(){var t=n.useState(f),u=t[0],c=t[1];return n.useEffect((function(){return r||(r=!0,m({initValue:e,useHookBody:o,applyStateChange:l})),i.push(c),a!==u&&c(a),function(){i.splice(i.indexOf(c),1)}}),[]),u}},h={singletonHook:y,SingletonHooksContainer:g};e.SingletonHooksContainer=g,e.default=h,e.singletonHook=y,Object.defineProperty(e,"__esModule",{value:!0})}));
!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="undefined"!=typeof globalThis?globalThis:e||self).ReactSingletonHook={},e.React,e.ReactDOM)}(this,(function(e,n,t){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=o(n);function u(){return(u=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 a=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)},f="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||this,l=!1,c=!1,s=!1,d=[],p=function(e){d.push(e)},y=function(){c=!0,n.useEffect((function(){l&&i("SingletonHooksContainer is mounted second time. You should mount SingletonHooksContainer before any other component and never unmount it.Alternatively, dont use SingletonHooksContainer it at all, we will handle that for you."),l=!0}),[]);var e=n.useState([]),t=e[0],o=e[1];return n.useEffect((function(){p=function(e){return o((function(n){return[].concat(n,[e])}))},o(d)}),[]),r.default.createElement(r.default.Fragment,null,t.map((function(e,n){return r.default.createElement(a,u({},e,{key:n}))})))},m=function(e){var n;c||s||(s=!0,n=y,f.document&&f.document.createElement?t.render(r.default.createElement(n,null),f.document.createElement("div")):i("Can not mount SingletonHooksContainer on server side. Did you manage to run useEffect on server? Please mount SingletonHooksContainer into your components tree manually.")),p(e)},g=function(e,o){var r=!1,u=!1,a=void 0,i=[],f=function(e){a=e,t.unstable_batchedUpdates((function(){return i.forEach((function(n){return n(e)}))}))},l=function(){return u||(a="function"==typeof e?e():e,u=!0),a};return function(){var t=n.useState(l),u=t[0],c=t[1];return n.useEffect((function(){return r||(r=!0,m({initValue:e,useHookBody:o,applyStateChange:f})),i.push(c),a!==u&&c(a),function(){i.splice(i.indexOf(c),1)}}),[]),u}},h={singletonHook:g,SingletonHooksContainer:y};e.SingletonHooksContainer=y,e.default=h,e.singletonHook=g,Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -25,5 +25,2 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

SingletonHooksContainerMounted = true;
return function () {
return process.env.NODE_ENV !== 'test' && warning('SingletonHooksContainer is removed from DOM. its not supported, singleton hooks will stop updating.');
};
}, []);

@@ -30,0 +27,0 @@

@@ -39,5 +39,2 @@ "use strict";

SingletonHooksContainerMounted = true;
return function () {
return process.env.NODE_ENV !== 'test' && (0, _warning.warning)('SingletonHooksContainer is removed from DOM. its not supported, singleton hooks will stop updating.');
};
}, []);

@@ -44,0 +41,0 @@

{
"name": "react-singleton-hook",
"version": "3.2.0",
"version": "3.2.1",
"description": "Share custom hook state across all components",

@@ -5,0 +5,0 @@ "keywords": [

@@ -23,3 +23,2 @@ import React, { useState, useEffect } from 'react';

SingletonHooksContainerMounted = true;
return () => process.env.NODE_ENV !== 'test' && warning('SingletonHooksContainer is removed from DOM. its not supported, singleton hooks will stop updating.');
}, []);

@@ -26,0 +25,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc