use-context-selector
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -5,2 +5,6 @@ # Change Log | ||
## [1.1.1] - 2020-03-02 | ||
### Changed | ||
- Avoid React render warning in test (#15) | ||
## [1.1.0] - 2020-02-24 | ||
@@ -7,0 +11,0 @@ ### Changed |
@@ -1,2 +0,2 @@ | ||
import e from"react";var r="production"!==process.env.NODE_ENV?Symbol("CONTEXT_LISTENERS"):Symbol(),t=function(t){var n,u,o=e.createContext(t,function(){return 0});return o[r]=new Set,o.Provider=(n=o.Provider,u=o[r],e.memo(function(r){var t=r.value,o=r.children;return"production"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV?e.useLayoutEffect(function(){u.forEach(function(e){e(t)})}):u.forEach(function(e){e(t)}),e.createElement(n,{value:t},o)})),delete o.Consumer,o},n=function(t,n){var u=t[r];if("production"!==process.env.NODE_ENV&&!u)throw new Error("useContextSelector requires special context");var o=e.useReducer(function(e){return e+1},0)[1],c=e.useContext(t),f=n(c),i=e.useRef(null);return e.useLayoutEffect(function(){i.current={f:n,v:c,s:f}}),e.useLayoutEffect(function(){var e=function(e){try{if(i.current.v===e||Object.is(i.current.s,i.current.f(e)))return}catch(e){}o()};return u.add(e),function(){u.delete(e)}},[u]),f},u=function(e){return n(e,function(e){return e})};export{t as createContext,u as useContext,n as useContextSelector}; | ||
import e from"react";var r="production"!==process.env.NODE_ENV?Symbol("CONTEXT_LISTENERS"):Symbol(),t=function(t){var n,u,o=e.createContext(t,function(){return 0});return o[r]=new Set,o.Provider=(n=o.Provider,u=o[r],e.memo(function(r){var t=r.value,o=r.children;return"production"!==process.env.NODE_ENV?e.useLayoutEffect(function(){u.forEach(function(e){e(t)})}):u.forEach(function(e){e(t)}),e.createElement(n,{value:t},o)})),delete o.Consumer,o},n=function(t,n){var u=t[r];if("production"!==process.env.NODE_ENV&&!u)throw new Error("useContextSelector requires special context");var o=e.useReducer(function(e){return e+1},0)[1],c=e.useContext(t),f=n(c),i=e.useRef(null);return e.useLayoutEffect(function(){i.current={f:n,v:c,s:f}}),e.useLayoutEffect(function(){var e=function(e){try{if(i.current.v===e||Object.is(i.current.s,i.current.f(e)))return}catch(e){}o()};return u.add(e),function(){u.delete(e)}},[u]),f},u=function(e){return n(e,function(e){return e})};export{t as createContext,u as useContext,n as useContextSelector}; | ||
//# sourceMappingURL=index.esm.js.map |
@@ -1,2 +0,2 @@ | ||
var e,t=(e=require("react"))&&"object"==typeof e&&"default"in e?e.default:e,r="production"!==process.env.NODE_ENV?Symbol("CONTEXT_LISTENERS"):Symbol(),n=function(e,n){var o=e[r];if("production"!==process.env.NODE_ENV&&!o)throw new Error("useContextSelector requires special context");var u=t.useReducer(function(e){return e+1},0)[1],c=t.useContext(e),f=n(c),i=t.useRef(null);return t.useLayoutEffect(function(){i.current={f:n,v:c,s:f}}),t.useLayoutEffect(function(){var e=function(e){try{if(i.current.v===e||Object.is(i.current.s,i.current.f(e)))return}catch(e){}u()};return o.add(e),function(){o.delete(e)}},[o]),f};exports.createContext=function(e){var n,o,u=t.createContext(e,function(){return 0});return u[r]=new Set,u.Provider=(n=u.Provider,o=u[r],t.memo(function(e){var r=e.value,u=e.children;return"production"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV?t.useLayoutEffect(function(){o.forEach(function(e){e(r)})}):o.forEach(function(e){e(r)}),t.createElement(n,{value:r},u)})),delete u.Consumer,u},exports.useContext=function(e){return n(e,function(e){return e})},exports.useContextSelector=n; | ||
var e,t=(e=require("react"))&&"object"==typeof e&&"default"in e?e.default:e,r="production"!==process.env.NODE_ENV?Symbol("CONTEXT_LISTENERS"):Symbol(),n=function(e,n){var u=e[r];if("production"!==process.env.NODE_ENV&&!u)throw new Error("useContextSelector requires special context");var o=t.useReducer(function(e){return e+1},0)[1],c=t.useContext(e),f=n(c),i=t.useRef(null);return t.useLayoutEffect(function(){i.current={f:n,v:c,s:f}}),t.useLayoutEffect(function(){var e=function(e){try{if(i.current.v===e||Object.is(i.current.s,i.current.f(e)))return}catch(e){}o()};return u.add(e),function(){u.delete(e)}},[u]),f};exports.createContext=function(e){var n,u,o=t.createContext(e,function(){return 0});return o[r]=new Set,o.Provider=(n=o.Provider,u=o[r],t.memo(function(e){var r=e.value,o=e.children;return"production"!==process.env.NODE_ENV?t.useLayoutEffect(function(){u.forEach(function(e){e(r)})}):u.forEach(function(e){e(r)}),t.createElement(n,{value:r},o)})),delete o.Consumer,o},exports.useContext=function(e){return n(e,function(e){return e})},exports.useContextSelector=n; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).useContextSelector={},e.react)}(this,function(e,t){t=t&&t.hasOwnProperty("default")?t.default:t;var n="production"!==process.env.NODE_ENV?Symbol("CONTEXT_LISTENERS"):Symbol(),r=function(e,r){var o=e[n];if("production"!==process.env.NODE_ENV&&!o)throw new Error("useContextSelector requires special context");var u=t.useReducer(function(e){return e+1},0)[1],c=t.useContext(e),f=r(c),i=t.useRef(null);return t.useLayoutEffect(function(){i.current={f:r,v:c,s:f}}),t.useLayoutEffect(function(){var e=function(e){try{if(i.current.v===e||Object.is(i.current.s,i.current.f(e)))return}catch(e){}u()};return o.add(e),function(){o.delete(e)}},[o]),f};e.createContext=function(e){var r,o,u=t.createContext(e,function(){return 0});return u[n]=new Set,u.Provider=(r=u.Provider,o=u[n],t.memo(function(e){var n=e.value,u=e.children;return"production"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV?t.useLayoutEffect(function(){o.forEach(function(e){e(n)})}):o.forEach(function(e){e(n)}),t.createElement(r,{value:n},u)})),delete u.Consumer,u},e.useContext=function(e){return r(e,function(e){return e})},e.useContextSelector=r}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).useContextSelector={},e.react)}(this,function(e,t){t=t&&t.hasOwnProperty("default")?t.default:t;var n="production"!==process.env.NODE_ENV?Symbol("CONTEXT_LISTENERS"):Symbol(),r=function(e,r){var o=e[n];if("production"!==process.env.NODE_ENV&&!o)throw new Error("useContextSelector requires special context");var u=t.useReducer(function(e){return e+1},0)[1],c=t.useContext(e),f=r(c),i=t.useRef(null);return t.useLayoutEffect(function(){i.current={f:r,v:c,s:f}}),t.useLayoutEffect(function(){var e=function(e){try{if(i.current.v===e||Object.is(i.current.s,i.current.f(e)))return}catch(e){}u()};return o.add(e),function(){o.delete(e)}},[o]),f};e.createContext=function(e){var r,o,u=t.createContext(e,function(){return 0});return u[n]=new Set,u.Provider=(r=u.Provider,o=u[n],t.memo(function(e){var n=e.value,u=e.children;return"production"!==process.env.NODE_ENV?t.useLayoutEffect(function(){o.forEach(function(e){e(n)})}):o.forEach(function(e){e(n)}),t.createElement(r,{value:n},u)})),delete u.Consumer,u},e.useContext=function(e){return r(e,function(e){return e})},e.useContextSelector=r}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "use-context-selector", | ||
"description": "React useContextSelector hook in userland", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"author": "Daishi Kato", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -9,3 +9,3 @@ import React from 'react'; | ||
const createProvider = (OrigProvider, listeners) => React.memo(({ value, children }) => { | ||
if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test') { | ||
if (process.env.NODE_ENV !== 'production') { | ||
// we use layout effect to eliminate warnings. | ||
@@ -12,0 +12,0 @@ // but, this leads tearing with startTransition. |
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
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
31548
12
12
129