context-state
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -1,1 +0,1 @@ | ||
"use strict";var e=require("./createContainer.js"),r=require("./utils/index.js");Object.defineProperty(exports,"createContainer",{enumerable:!0,get:function(){return e.createContainer}}),Object.defineProperty(exports,"shallowEqual",{enumerable:!0,get:function(){return r.shallowEqual}}); | ||
"use strict";var e=require("./createContainer.js");var r=require("./utils/index.js");Object.defineProperty(exports,"createContainer",{enumerable:true,get:function r(){return e.createContainer}});Object.defineProperty(exports,"shallowEqual",{enumerable:true,get:function e(){return r.shallowEqual}}); |
@@ -0,1 +1,10 @@ | ||
## [2.2.1](https://github.com/hemengke1997/context-state/compare/v2.2.0...v2.2.1) (2024-03-04) | ||
### Performance Improvements | ||
* enhance browser compatibility ([279a104](https://github.com/hemengke1997/context-state/commit/279a1042ee61a0f3c2d6a86629b8f8b0f5abb1c1)) | ||
# [2.2.0](https://github.com/hemengke1997/context-state/compare/v2.0.0...v2.2.0) (2024-02-29) | ||
@@ -2,0 +11,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";var e,r=require("react"),t=require("./utils/index.js"),n="[context-state]: Component must be wrapped with <Container.Provider>",o=Symbol("CONTEXT_VALUE"),u=Symbol("EMPTY");exports.createContainer=function(c){const s=r.createContext(u);let i;function l(c,l=t.shallowEqual){var a;const f=r.useContext(s);let E=null==f?void 0:f[o];if(f===u){if("production"===process.env.NODE_ENV)throw new Error(n);{const r=null==(a=e.get(i))?void 0:a[o];if(!r)throw new Error(n);E=r}}const{v:{current:d},l:v}=E,[,p]=t.useSafeState(0),h=c(d),w=r.useRef();return w.current={value:d,selected:h},t.useIsomorphicLayoutEffect((()=>{function e(e){try{if(!w.current)return;if(w.current.value===e)return;const r=c(e);if(l(w.current.selected,r))return;p((e=>e+1))}catch(e){}}return v.add(e),()=>{v.delete(e)}}),[]),h}return"production"!==process.env.NODE_ENV&&(i=c.toString()),{Provider:({value:n,children:u})=>{const l=c(n),a=r.useRef(l),f=r.useRef();if(!f.current){const e=new Set;f.current={[o]:{v:a,l:e}}}return"production"!==process.env.NODE_ENV&&("production"!==process.env.NODE_ENV&&(e||(e=new Map)),e.set(i,f.current)),t.useIsomorphicLayoutEffect((()=>{var e;a.current=l,null==(e=f.current)||e[o].l.forEach((e=>{e(l)}))}),[l]),r.createElement(s.Provider,{value:f.current},u)},Consumer:({children:e})=>e(l((e=>e))),useSelector:l,usePicker:function(e,r=t.shallowEqual){return l((r=>t.pick(r,e)),r)}}}; | ||
"use strict";function r(r,e){if(e==null||e>r.length)e=r.length;for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function e(r){if(Array.isArray(r))return r}function t(r,e,t){if(e in r){Object.defineProperty(r,e,{value:t,enumerable:true,configurable:true,writable:true})}else{r[e]=t}return r}function n(r,e){var t=r==null?null:typeof Symbol!=="undefined"&&r[Symbol.iterator]||r["@@iterator"];if(t==null)return;var n=[];var u=true;var o=false;var a,i;try{for(t=t.call(r);!(u=(a=t.next()).done);u=true){n.push(a.value);if(e&&n.length===e)break}}catch(r){o=true;i=r}finally{try{if(!u&&t["return"]!=null)t["return"]()}finally{if(o)throw i}}return n}function u(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(r,t){return e(r)||n(r,t)||a(r,t)||u()}function a(e,t){if(!e)return;if(typeof e==="string")return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}var i=require("react");var c=require("./utils/index.js");var l="[context-state]: Component must be wrapped with <Container.Provider>",f=Symbol("CONTEXT_VALUE"),v=Symbol("EMPTY");function s(r){var e=function r(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:c.shallowEqual;var t=i.useContext(u),n=t===null||t===void 0?void 0:t[f];if(t===v)throw new Error(l);var a=n.v,s=a.current,d=n.l,y=o(c.useSafeState(0),2),h=y[1],m=r(s),b=i.useRef();return b.current={value:s,selected:m},c.useIsomorphicLayoutEffect(function(){function t(t){try{if(!b.current||b.current.value===t)return;var n=r(t);if(e(b.current.selected,n))return;h(function(r){return r+1})}catch(r){}}return d.add(t),function(){d["delete"](t)}},[]),m};var n=function r(r){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:c.shallowEqual;return e(function(e){return c.pick(e,r)},t)};var u=i.createContext(v),a=function(e){var n=e.value,o=e.children;var a=r(n),l=i.useRef(a),v=i.useRef();if(!v.current){var s=new Set;v.current=t({},f,{v:l,l:s})}return c.useIsomorphicLayoutEffect(function(){var r;l.current=a,(r=v.current)===null||r===void 0?void 0:r[f].l.forEach(function(r){r(a)})},[a]),i.createElement(u.Provider,{value:v.current},o)},s=function(r){var t=r.children;return t(e(function(r){return r}))};return{Provider:a,Consumer:s,useSelector:e,usePicker:n}}exports.createContainer=s; |
@@ -1,1 +0,1 @@ | ||
import{createContext as r,useRef as e,createElement as t,useContext as n}from"react";import{useIsomorphicLayoutEffect as o,useSafeState as c,shallowEqual as u,pick as i}from"./utils/index.js";var s,l="[context-state]: Component must be wrapped with <Container.Provider>",d=Symbol("CONTEXT_VALUE"),v=Symbol("EMPTY");function a(a){const p=r(v);let f;"production"!==process.env.NODE_ENV&&(f=a.toString());function E(r,t=u){var i;const a=n(p);let E=null==a?void 0:a[d];if(a===v){if("production"===process.env.NODE_ENV)throw new Error(l);{const r=null==(i=s.get(f))?void 0:i[d];if(!r)throw new Error(l);E=r}}const{v:{current:m},l:N}=E,[,w]=c(0),h=r(m),O=e();return O.current={value:m,selected:h},o((()=>{function e(e){try{if(!O.current)return;if(O.current.value===e)return;const n=r(e);if(t(O.current.selected,n))return;w((r=>r+1))}catch(r){}}return N.add(e),()=>{N.delete(e)}}),[]),h}return{Provider:({value:r,children:n})=>{const c=a(r),u=e(c),i=e();if(!i.current){const r=new Set;i.current={[d]:{v:u,l:r}}}return"production"!==process.env.NODE_ENV&&("production"!==process.env.NODE_ENV&&(s||(s=new Map)),s.set(f,i.current)),o((()=>{var r;u.current=c,null==(r=i.current)||r[d].l.forEach((r=>{r(c)}))}),[c]),t(p.Provider,{value:i.current},n)},Consumer:({children:r})=>r(E((r=>r))),useSelector:E,usePicker:function(r,e=u){return E((e=>i(e,r)),e)}}}export{a as createContainer}; | ||
function r(r,t){if(t==null||t>r.length)t=r.length;for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}function t(r){if(Array.isArray(r))return r}function e(r,t,e){if(t in r){Object.defineProperty(r,t,{value:e,enumerable:true,configurable:true,writable:true})}else{r[t]=e}return r}function n(r,t){var e=r==null?null:typeof Symbol!=="undefined"&&r[Symbol.iterator]||r["@@iterator"];if(e==null)return;var n=[];var u=true;var o=false;var i,a;try{for(e=e.call(r);!(u=(i=e.next()).done);u=true){n.push(i.value);if(t&&n.length===t)break}}catch(r){o=true;a=r}finally{try{if(!u&&e["return"]!=null)e["return"]()}finally{if(o)throw a}}return n}function u(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(r,e){return t(r)||n(r,e)||i(r,e)||u()}function i(t,e){if(!t)return;if(typeof t==="string")return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor)n=t.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}import{createContext as a,useRef as c,createElement as l,useContext as f}from"react";import{useIsomorphicLayoutEffect as v,useSafeState as d,shallowEqual as s,pick as y}from"./utils/index.js";var m="[context-state]: Component must be wrapped with <Container.Provider>",b=Symbol("CONTEXT_VALUE"),h=Symbol("EMPTY");function p(r){var t=function r(r){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:s;var e=f(u),n=e===null||e===void 0?void 0:e[b];if(e===h)throw new Error(m);var i=n.v,a=i.current,l=n.l,y=o(d(0),2),p=y[1],w=r(a),g=c();return g.current={value:a,selected:w},v(function(){function e(e){try{if(!g.current||g.current.value===e)return;var n=r(e);if(t(g.current.selected,n))return;p(function(r){return r+1})}catch(r){}}return l.add(e),function(){l["delete"](e)}},[]),w};var n=function r(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:s;return t(function(t){return y(t,r)},e)};var u=a(h),i=function(t){var n=t.value,o=t.children;var i=r(n),a=c(i),f=c();if(!f.current){var d=new Set;f.current=e({},b,{v:a,l:d})}return v(function(){var r;a.current=i,(r=f.current)===null||r===void 0?void 0:r[b].l.forEach(function(r){r(i)})},[i]),l(u.Provider,{value:f.current},o)},p=function(r){var e=r.children;return e(t(function(r){return r}))};return{Provider:i,Consumer:p,useSelector:t,usePicker:n}}export{p as createContainer}; |
@@ -1,1 +0,1 @@ | ||
function n(n,t){const c={};return n?Object.assign(c,...t.map((t=>({[t]:n[t]})))):c}export{n as pick}; | ||
function r(r,t){if(t==null||t>r.length)t=r.length;for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}function t(t){if(Array.isArray(t))return r(t)}function e(r,t,e){if(t in r){Object.defineProperty(r,t,{value:e,enumerable:true,configurable:true,writable:true})}else{r[t]=e}return r}function n(r){if(typeof Symbol!=="undefined"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function o(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function i(r){return t(r)||n(r)||a(r)||o()}function a(t,e){if(!t)return;if(typeof t==="string")return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor)n=t.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}function u(r,t){var n;var o={};return r?(n=Object).assign.apply(n,[o].concat(i(t.map(function(t){return e({},t,r[t])})))):o}export{u as pick}; |
@@ -1,1 +0,1 @@ | ||
function e(e,t){return!!Object.is(e,t)||!!(e&&"object"==typeof e&&t&&"object"==typeof t&&[...Object.keys(e),...Object.keys(t)].every((o=>e[o]===t[o]&&Object.prototype.hasOwnProperty.call(e,o)&&Object.prototype.hasOwnProperty.call(t,o))))}export{e as shallowEqual}; | ||
function t(t,r){if(r==null||r>t.length)r=t.length;for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function r(r){if(Array.isArray(r))return t(r)}function e(t){if(typeof Symbol!=="undefined"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function n(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(t){return r(t)||e(t)||a(t)||n()}function a(r,e){if(!r)return;if(typeof r==="string")return t(r,e);var n=Object.prototype.toString.call(r).slice(8,-1);if(n==="Object"&&r.constructor)n=r.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t(r,e)}function i(t,r){return!!(Object.is(t,r)||t&&typeof t=="object"&&r&&typeof r=="object"&&o(Object.keys(t)).concat(o(Object.keys(r))).every(function(e){return t[e]===r[e]&&Object.prototype.hasOwnProperty.call(t,e)&&Object.prototype.hasOwnProperty.call(r,e)}))}export{i as shallowEqual}; |
@@ -1,1 +0,1 @@ | ||
import{useLayoutEffect as e,useEffect as o}from"react";var d="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?e:o;export{d as useIsomorphicLayoutEffect}; | ||
var e=function(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e};import{useLayoutEffect as o,useEffect as n}from"react";var t=(typeof window==="undefined"?"undefined":e(window))<"u"&&e(window.document)<"u"&&e(window.document.createElement)<"u"?o:n;export{t as useIsomorphicLayoutEffect}; |
@@ -1,1 +0,1 @@ | ||
import{useState as r,useCallback as t,useRef as n,useEffect as c}from"react";function e(e){const o=(()=>{const r=n(!1);return c((()=>(r.current=!1,()=>{r.current=!0})),[]),r})(),[u,f]=r(e);return[u,t((r=>{o.current||f(r)}),[])]}export{e as useSafeState}; | ||
function r(r,t){if(t==null||t>r.length)t=r.length;for(var n=0,e=new Array(t);n<t;n++)e[n]=r[n];return e}function t(r){if(Array.isArray(r))return r}function n(r,t){var n=r==null?null:typeof Symbol!=="undefined"&&r[Symbol.iterator]||r["@@iterator"];if(n==null)return;var e=[];var u=true;var o=false;var a,i;try{for(n=n.call(r);!(u=(a=n.next()).done);u=true){e.push(a.value);if(t&&e.length===t)break}}catch(r){o=true;i=r}finally{try{if(!u&&n["return"]!=null)n["return"]()}finally{if(o)throw i}}return e}function e(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(r,u){return t(r)||n(r,u)||o(r,u)||e()}function o(t,n){if(!t)return;if(typeof t==="string")return r(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor)e=t.constructor.name;if(e==="Map"||e==="Set")return Array.from(e);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return r(t,n)}import{useState as a,useCallback as i,useRef as f,useEffect as l}from"react";var c=function(){var r=f(!1);return l(function(){return r.current=!1,function(){r.current=!0}},[]),r};function y(r){var t=c(),n=u(a(r),2),e=n[0],o=n[1],f=i(function(r){t.current||o(r)},[]);return[e,f]}export{y as useSafeState}; |
@@ -1,1 +0,1 @@ | ||
"use strict";var e=require("./createContainer.js"),r=require("./utils/index.js");Object.defineProperty(exports,"createContainer",{enumerable:!0,get:function(){return e.createContainer}}),Object.defineProperty(exports,"shallowEqual",{enumerable:!0,get:function(){return r.shallowEqual}}); | ||
"use strict";var e=require("./createContainer.js");var r=require("./utils/index.js");Object.defineProperty(exports,"createContainer",{enumerable:true,get:function r(){return e.createContainer}});Object.defineProperty(exports,"shallowEqual",{enumerable:true,get:function e(){return r.shallowEqual}}); |
@@ -1,1 +0,1 @@ | ||
"use strict";var e=require("./pick.js"),t=require("./shallowEqual.js"),r=require("./useIsomorphicLayoutEffect.js"),o=require("./useSafeState.js");Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})})),Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(r).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return r[e]}})})),Object.keys(o).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return o[e]}})})); | ||
"use strict";var e=require("./pick.js");var t=require("./shallowEqual.js");var r=require("./useIsomorphicLayoutEffect.js");var o=require("./useSafeState.js");Object.keys(e).forEach(function(t){if(t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t))Object.defineProperty(exports,t,{enumerable:true,get:function r(){return e[t]}})});Object.keys(t).forEach(function(e){if(e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e))Object.defineProperty(exports,e,{enumerable:true,get:function r(){return t[e]}})});Object.keys(r).forEach(function(e){if(e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e))Object.defineProperty(exports,e,{enumerable:true,get:function t(){return r[e]}})});Object.keys(o).forEach(function(e){if(e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e))Object.defineProperty(exports,e,{enumerable:true,get:function t(){return o[e]}})}); |
@@ -1,1 +0,1 @@ | ||
"use strict";exports.pick=function(t,s){const c={};return t?Object.assign(c,...s.map((s=>({[s]:t[s]})))):c}; | ||
"use strict";function r(r,t){if(t==null||t>r.length)t=r.length;for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}function t(t){if(Array.isArray(t))return r(t)}function e(r,t,e){if(t in r){Object.defineProperty(r,t,{value:e,enumerable:true,configurable:true,writable:true})}else{r[t]=e}return r}function n(r){if(typeof Symbol!=="undefined"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function o(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function i(r){return t(r)||n(r)||a(r)||o()}function a(t,e){if(!t)return;if(typeof t==="string")return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor)n=t.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}function u(r,t){var n;var o={};return r?(n=Object).assign.apply(n,[o].concat(i(t.map(function(t){return e({},t,r[t])})))):o}exports.pick=u; |
@@ -1,1 +0,1 @@ | ||
"use strict";exports.shallowEqual=function(e,t){return!!Object.is(e,t)||!!(e&&"object"==typeof e&&t&&"object"==typeof t&&[...Object.keys(e),...Object.keys(t)].every((o=>e[o]===t[o]&&Object.prototype.hasOwnProperty.call(e,o)&&Object.prototype.hasOwnProperty.call(t,o))))}; | ||
"use strict";function t(t,r){if(r==null||r>t.length)r=t.length;for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function r(r){if(Array.isArray(r))return t(r)}function e(t){if(typeof Symbol!=="undefined"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function n(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(t){return r(t)||e(t)||a(t)||n()}function a(r,e){if(!r)return;if(typeof r==="string")return t(r,e);var n=Object.prototype.toString.call(r).slice(8,-1);if(n==="Object"&&r.constructor)n=r.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t(r,e)}function i(t,r){return!!(Object.is(t,r)||t&&typeof t=="object"&&r&&typeof r=="object"&&o(Object.keys(t)).concat(o(Object.keys(r))).every(function(e){return t[e]===r[e]&&Object.prototype.hasOwnProperty.call(t,e)&&Object.prototype.hasOwnProperty.call(r,e)}))}exports.shallowEqual=i; |
@@ -1,1 +0,1 @@ | ||
"use strict";var e=require("react"),t="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?e.useLayoutEffect:e.useEffect;exports.useIsomorphicLayoutEffect=t; | ||
"use strict";var e=function(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e};var o=require("react");var t=(typeof window==="undefined"?"undefined":e(window))<"u"&&e(window.document)<"u"&&e(window.document.createElement)<"u"?o.useLayoutEffect:o.useEffect;exports.useIsomorphicLayoutEffect=t; |
@@ -1,1 +0,1 @@ | ||
"use strict";var e=require("react");exports.useSafeState=function(t){const r=(()=>{const t=e.useRef(!1);return e.useEffect((()=>(t.current=!1,()=>{t.current=!0})),[]),t})(),[u,c]=e.useState(t);return[u,e.useCallback((e=>{r.current||c(e)}),[])]}; | ||
"use strict";function r(r,t){if(t==null||t>r.length)t=r.length;for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}function t(r){if(Array.isArray(r))return r}function e(r,t){var e=r==null?null:typeof Symbol!=="undefined"&&r[Symbol.iterator]||r["@@iterator"];if(e==null)return;var n=[];var u=true;var a=false;var o,i;try{for(e=e.call(r);!(u=(o=e.next()).done);u=true){n.push(o.value);if(t&&n.length===t)break}}catch(r){a=true;i=r}finally{try{if(!u&&e["return"]!=null)e["return"]()}finally{if(a)throw i}}return n}function n(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(r,u){return t(r)||e(r,u)||a(r,u)||n()}function a(t,e){if(!t)return;if(typeof t==="string")return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor)n=t.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}var o=require("react");var i=function(){var r=o.useRef(!1);return o.useEffect(function(){return r.current=!1,function(){r.current=!0}},[]),r};function f(r){var t=i(),e=u(o.useState(r),2),n=e[0],a=e[1],f=o.useCallback(function(r){t.current||a(r)},[]);return[n,f]}exports.useSafeState=f; |
{ | ||
"name": "context-state", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "React state management library", | ||
@@ -43,3 +43,2 @@ "keywords": [ | ||
}, | ||
"sideEffects": false, | ||
"peerDependencies": { | ||
@@ -46,0 +45,0 @@ "react": ">=16.8.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances 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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
32756
0