@loadable/component
Advanced tools
Comparing version 5.10.1 to 5.10.2
@@ -6,2 +6,13 @@ # Change Log | ||
## [5.10.2](https://github.com/smooth-code/loadable-components/compare/v5.10.1...v5.10.2) (2019-07-15) | ||
### Bug Fixes | ||
* use === instead of Object.is ([c88cd82](https://github.com/smooth-code/loadable-components/commit/c88cd82)), closes [#371](https://github.com/smooth-code/loadable-components/issues/371) | ||
## [5.10.1](https://github.com/smooth-code/loadable-components/compare/v5.10.0...v5.10.1) (2019-05-14) | ||
@@ -8,0 +19,0 @@ |
@@ -158,3 +158,3 @@ 'use strict'; | ||
// Component is reloaded if the cacheKey has changed | ||
if (!Object.is(prevState.cacheKey, this.state.cacheKey)) { | ||
if (prevState.cacheKey !== this.state.cacheKey) { | ||
this.promise = null; | ||
@@ -161,0 +161,0 @@ this.loadAsync(); |
@@ -152,3 +152,3 @@ import React from 'react'; | ||
// Component is reloaded if the cacheKey has changed | ||
if (!Object.is(prevState.cacheKey, this.state.cacheKey)) { | ||
if (prevState.cacheKey !== this.state.cacheKey) { | ||
this.promise = null; | ||
@@ -155,0 +155,0 @@ this.loadAsync(); |
@@ -201,3 +201,3 @@ (function (global, factory) { | ||
// Component is reloaded if the cacheKey has changed | ||
if (!Object.is(prevState.cacheKey, this.state.cacheKey)) { | ||
if (prevState.cacheKey !== this.state.cacheKey) { | ||
this.promise = null; | ||
@@ -204,0 +204,0 @@ this.loadAsync(); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("hoist-non-react-statics")):"function"==typeof define&&define.amd?define(["exports","react","hoist-non-react-statics"],t):t((e=e||self).loadable={},e.React,e.hoistNonReactStatics)}(this,function(e,t,r){"use strict";function n(e,t){if(!e){var r=new Error("loadable: "+t);throw r.framesToPop=1,r.name="Invariant Violation",r}}function o(e){console.warn("loadable: "+e)}t=t&&t.hasOwnProperty("default")?t.default:t,r=r&&r.hasOwnProperty("default")?r.default:r;var a=t.createContext(),i="__LOADABLE_REQUIRED_CHUNKS__";function s(e){return""+e+i}var u=Object.freeze({getRequiredChunkKey:s,invariant:n,Context:a});function c(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}function l(){return(l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function f(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var d=function(e){return function(r){return t.createElement(a.Consumer,null,function(n){return t.createElement(e,Object.assign({__chunkExtractor:n},r))})}},h=function(e){return e};function p(e){var r=e.resolve,o=void 0===r?h:r,a=e.render,i=e.onLoad;function s(e,r){void 0===r&&(r={});var s=function(e){return"function"==typeof e?{requireAsync:e}:e}(e),u={};function h(e){return r.cacheKey?r.cacheKey(e):s.resolve?s.resolve(e):null}var p=function(e){var t,d;function p(t){var o;return(o=e.call(this,t)||this).state={result:null,error:null,loading:!0,cacheKey:h(t)},o.promise=null,n(!t.__chunkExtractor||s.requireSync,"SSR requires `@loadable/babel-plugin`, please install it"),t.__chunkExtractor?!1===r.ssr?f(o):(s.requireAsync(t).catch(function(){}),o.loadSync(),t.__chunkExtractor.addChunk(s.chunkName(t)),f(o)):(s.isReady&&s.isReady(t)&&o.loadSync(),o)}d=e,(t=p).prototype=Object.create(d.prototype),t.prototype.constructor=t,t.__proto__=d,p.getDerivedStateFromProps=function(e,t){var r=h(e);return l({},t,{cacheKey:r,loading:t.loading||t.cacheKey!==r})};var _=p.prototype;return _.componentDidMount=function(){this.mounted=!0,this.state.loading?this.loadAsync():this.state.error||this.triggerOnLoad()},_.componentDidUpdate=function(e,t){Object.is(t.cacheKey,this.state.cacheKey)||(this.promise=null,this.loadAsync())},_.componentWillUnmount=function(){this.mounted=!1},_.safeSetState=function(e,t){this.mounted&&this.setState(e,t)},_.triggerOnLoad=function(){var e=this;i&&setTimeout(function(){i(e.state.result,e.props)})},_.loadSync=function(){if(this.state.loading)try{var e=s.requireSync(this.props),t=o(e,{Loadable:y});this.state.result=t,this.state.loading=!1}catch(e){this.state.error=e}},_.getCacheKey=function(){return h(this.props)||JSON.stringify(this.props)},_.getCache=function(){return u[this.getCacheKey()]},_.setCache=function(e){u[this.getCacheKey()]=e},_.loadAsync=function(){var e=this;if(!this.promise){var t=this.props,n=(t.__chunkExtractor,t.forwardedRef,c(t,["__chunkExtractor","forwardedRef"]));this.promise=s.requireAsync(n).then(function(t){var n=o(t,{Loadable:y});r.suspense&&e.setCache(n),e.safeSetState({result:o(t,{Loadable:y}),loading:!1},function(){return e.triggerOnLoad()})}).catch(function(t){e.safeSetState({error:t,loading:!1})})}return this.promise},_.render=function(){var e=this.props,t=e.forwardedRef,n=e.fallback,o=(e.__chunkExtractor,c(e,["forwardedRef","fallback","__chunkExtractor"])),i=this.state,s=i.error,u=i.loading,f=i.result;if(r.suspense){var d=this.getCache();if(!d)throw this.loadAsync();return a({loading:!1,fallback:null,result:d,options:r,props:l({},o,{ref:t})})}if(s)throw s;var h=n||r.fallback||null;return u?h:a({loading:u,fallback:h,result:f,options:r,props:l({},o,{ref:t})})},p}(t.Component),_=d(p),y=t.forwardRef(function(e,r){return t.createElement(_,Object.assign({forwardedRef:r},e))});return y.preload=function(e){s.requireAsync(e)},y.load=function(e){return s.requireAsync(e)},y}return{loadable:s,lazy:function(e,t){return s(e,l({},t,{suspense:!0}))}}}var _=p({resolve:function(e,t){var n=t.Loadable,o=e.__esModule?e.default:e.default||e;return r(n,o,{preload:!0}),o},render:function(e){var r=e.result,n=e.props;return t.createElement(r,n)}}),y=_.loadable,v=_.lazy,b=p({onLoad:function(e,t){e&&t.forwardedRef&&("function"==typeof t.forwardedRef?t.forwardedRef(e):t.forwardedRef.current=e)},render:function(e){var t=e.result,r=e.loading,n=e.props;return!r&&n.children?n.children(t):null}}),g=b.loadable,m=b.lazy,E="undefined"!=typeof window;var w=y;w.lib=g;var O=v;O.lib=m;var S=u;e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=S,e.default=w,e.lazy=O,e.loadableReady=function(e,t){void 0===e&&(e=function(){});var r=(void 0===t?{}:t).namespace,n=void 0===r?"":r;if(!E)return o("`loadableReady()` must be called in browser only"),e(),Promise.resolve();var a=null;if(E){var i=document.getElementById(s(n));i&&(a=JSON.parse(i.textContent))}if(!a)return o("`loadableReady()` requires state, please use `getScriptTags` or `getScriptElements` server-side"),e(),Promise.resolve();var u=!1;return new Promise(function(t){window.__LOADABLE_LOADED_CHUNKS__=window.__LOADABLE_LOADED_CHUNKS__||[];var r=window.__LOADABLE_LOADED_CHUNKS__,n=r.push.bind(r);function o(){a.every(function(e){return r.some(function(t){return t[0].includes(e)})})&&(u||(u=!0,t(),e()))}r.push=function(){n.apply(void 0,arguments),o()},o()})},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("hoist-non-react-statics")):"function"==typeof define&&define.amd?define(["exports","react","hoist-non-react-statics"],t):t((e=e||self).loadable={},e.React,e.hoistNonReactStatics)}(this,function(e,t,r){"use strict";function n(e,t){if(!e){var r=new Error("loadable: "+t);throw r.framesToPop=1,r.name="Invariant Violation",r}}function o(e){console.warn("loadable: "+e)}t=t&&t.hasOwnProperty("default")?t.default:t,r=r&&r.hasOwnProperty("default")?r.default:r;var a=t.createContext(),i="__LOADABLE_REQUIRED_CHUNKS__";function u(e){return""+e+i}var s=Object.freeze({getRequiredChunkKey:u,invariant:n,Context:a});function c(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}function l(){return(l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function f(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var d=function(e){return function(r){return t.createElement(a.Consumer,null,function(n){return t.createElement(e,Object.assign({__chunkExtractor:n},r))})}},h=function(e){return e};function p(e){var r=e.resolve,o=void 0===r?h:r,a=e.render,i=e.onLoad;function u(e,r){void 0===r&&(r={});var u=function(e){return"function"==typeof e?{requireAsync:e}:e}(e),s={};function h(e){return r.cacheKey?r.cacheKey(e):u.resolve?u.resolve(e):null}var p=function(e){var t,d;function p(t){var o;return(o=e.call(this,t)||this).state={result:null,error:null,loading:!0,cacheKey:h(t)},o.promise=null,n(!t.__chunkExtractor||u.requireSync,"SSR requires `@loadable/babel-plugin`, please install it"),t.__chunkExtractor?!1===r.ssr?f(o):(u.requireAsync(t).catch(function(){}),o.loadSync(),t.__chunkExtractor.addChunk(u.chunkName(t)),f(o)):(u.isReady&&u.isReady(t)&&o.loadSync(),o)}d=e,(t=p).prototype=Object.create(d.prototype),t.prototype.constructor=t,t.__proto__=d,p.getDerivedStateFromProps=function(e,t){var r=h(e);return l({},t,{cacheKey:r,loading:t.loading||t.cacheKey!==r})};var _=p.prototype;return _.componentDidMount=function(){this.mounted=!0,this.state.loading?this.loadAsync():this.state.error||this.triggerOnLoad()},_.componentDidUpdate=function(e,t){t.cacheKey!==this.state.cacheKey&&(this.promise=null,this.loadAsync())},_.componentWillUnmount=function(){this.mounted=!1},_.safeSetState=function(e,t){this.mounted&&this.setState(e,t)},_.triggerOnLoad=function(){var e=this;i&&setTimeout(function(){i(e.state.result,e.props)})},_.loadSync=function(){if(this.state.loading)try{var e=u.requireSync(this.props),t=o(e,{Loadable:y});this.state.result=t,this.state.loading=!1}catch(e){this.state.error=e}},_.getCacheKey=function(){return h(this.props)||JSON.stringify(this.props)},_.getCache=function(){return s[this.getCacheKey()]},_.setCache=function(e){s[this.getCacheKey()]=e},_.loadAsync=function(){var e=this;if(!this.promise){var t=this.props,n=(t.__chunkExtractor,t.forwardedRef,c(t,["__chunkExtractor","forwardedRef"]));this.promise=u.requireAsync(n).then(function(t){var n=o(t,{Loadable:y});r.suspense&&e.setCache(n),e.safeSetState({result:o(t,{Loadable:y}),loading:!1},function(){return e.triggerOnLoad()})}).catch(function(t){e.safeSetState({error:t,loading:!1})})}return this.promise},_.render=function(){var e=this.props,t=e.forwardedRef,n=e.fallback,o=(e.__chunkExtractor,c(e,["forwardedRef","fallback","__chunkExtractor"])),i=this.state,u=i.error,s=i.loading,f=i.result;if(r.suspense){var d=this.getCache();if(!d)throw this.loadAsync();return a({loading:!1,fallback:null,result:d,options:r,props:l({},o,{ref:t})})}if(u)throw u;var h=n||r.fallback||null;return s?h:a({loading:s,fallback:h,result:f,options:r,props:l({},o,{ref:t})})},p}(t.Component),_=d(p),y=t.forwardRef(function(e,r){return t.createElement(_,Object.assign({forwardedRef:r},e))});return y.preload=function(e){u.requireAsync(e)},y.load=function(e){return u.requireAsync(e)},y}return{loadable:u,lazy:function(e,t){return u(e,l({},t,{suspense:!0}))}}}var _=p({resolve:function(e,t){var n=t.Loadable,o=e.__esModule?e.default:e.default||e;return r(n,o,{preload:!0}),o},render:function(e){var r=e.result,n=e.props;return t.createElement(r,n)}}),y=_.loadable,v=_.lazy,b=p({onLoad:function(e,t){e&&t.forwardedRef&&("function"==typeof t.forwardedRef?t.forwardedRef(e):t.forwardedRef.current=e)},render:function(e){var t=e.result,r=e.loading,n=e.props;return!r&&n.children?n.children(t):null}}),g=b.loadable,m=b.lazy,E="undefined"!=typeof window;var w=y;w.lib=g;var O=v;O.lib=m;var S=s;e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=S,e.default=w,e.lazy=O,e.loadableReady=function(e,t){void 0===e&&(e=function(){});var r=(void 0===t?{}:t).namespace,n=void 0===r?"":r;if(!E)return o("`loadableReady()` must be called in browser only"),e(),Promise.resolve();var a=null;if(E){var i=document.getElementById(u(n));i&&(a=JSON.parse(i.textContent))}if(!a)return o("`loadableReady()` requires state, please use `getScriptTags` or `getScriptElements` server-side"),e(),Promise.resolve();var s=!1;return new Promise(function(t){window.__LOADABLE_LOADED_CHUNKS__=window.__LOADABLE_LOADED_CHUNKS__||[];var r=window.__LOADABLE_LOADED_CHUNKS__,n=r.push.bind(r);function o(){a.every(function(e){return r.some(function(t){return t[0].includes(e)})})&&(s||(s=!0,t(),e()))}r.push=function(){n.apply(void 0,arguments),o()},o()})},Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "@loadable/component", | ||
"description": "React code splitting made easy.", | ||
"version": "5.10.1", | ||
"version": "5.10.2", | ||
"main": "dist/loadable.cjs.js", | ||
@@ -39,3 +39,3 @@ "module": "dist/loadable.esm.js", | ||
}, | ||
"gitHead": "62adb11cc54e012011c01e492bc4d92a8ef0dd65" | ||
"gitHead": "1281ad3c5e1aa86b7ed018872d4e80f425c6e71d" | ||
} |
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
54472