why-did-you-update
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -50,4 +50,4 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
// the wrapper class extends the original class, | ||
// and overwrites its `componentDidUpdate` method, | ||
// the wrapper class extends the original class, | ||
// and overwrites its `componentDidUpdate` method, | ||
// to allow why-did-you-update to listen for updates. | ||
@@ -96,3 +96,3 @@ // If the component had its own `componentDidUpdate`, | ||
WDYUFunctionalComponent.prototype.render = function render() { | ||
return ctor(this.props); | ||
return ctor(this.props, this.context); | ||
}; | ||
@@ -106,5 +106,11 @@ | ||
}(ReactComponent); | ||
// our wrapper component needs an explicit display name | ||
// based on the original constructor. | ||
WDYUFunctionalComponent.displayName = getDisplayName(ctor); | ||
// copy all statics from the functional component to the class | ||
// to support proptypes and context apis | ||
Object.assign(WDYUFunctionalComponent, ctor, { | ||
// our wrapper component needs an explicit display name | ||
// based on the original constructor. | ||
displayName: getDisplayName(ctor) | ||
}); | ||
return WDYUFunctionalComponent; | ||
@@ -120,6 +126,6 @@ }; | ||
// which we're going to reference in our own implementation | ||
// and which we put back when we remove `whyDidYouUpdate` from React. | ||
// and which we put back when we remove `whyDidYouUpdate` from React. | ||
var _createReactElement = React.createElement; | ||
// The memoizer is a JavaScript map that allows us to return | ||
// The memoizer is a JavaScript map that allows us to return | ||
// the same WrappedComponent for the same original constructor. | ||
@@ -130,3 +136,3 @@ // This ensure that by wrapping the constructor, we don't break | ||
// Our new implementation of `React.createElement` works by | ||
// Our new implementation of `React.createElement` works by | ||
// replacing the element constructor with a class that wraps it. | ||
@@ -145,3 +151,3 @@ React.createElement = function (type) { | ||
} else { | ||
// If the constructor function has no `render`, | ||
// If the constructor function has no `render`, | ||
// it must be a simple functioanl component. | ||
@@ -154,3 +160,3 @@ ctor = memoized(memo, ctor, function () { | ||
// Call the old `React.createElement, | ||
// Call the old `React.createElement, | ||
// but with our overwritten constructor | ||
@@ -157,0 +163,0 @@ |
@@ -58,4 +58,4 @@ 'use strict'; | ||
// the wrapper class extends the original class, | ||
// and overwrites its `componentDidUpdate` method, | ||
// the wrapper class extends the original class, | ||
// and overwrites its `componentDidUpdate` method, | ||
// to allow why-did-you-update to listen for updates. | ||
@@ -104,3 +104,3 @@ // If the component had its own `componentDidUpdate`, | ||
WDYUFunctionalComponent.prototype.render = function render() { | ||
return ctor(this.props); | ||
return ctor(this.props, this.context); | ||
}; | ||
@@ -114,5 +114,11 @@ | ||
}(ReactComponent); | ||
// our wrapper component needs an explicit display name | ||
// based on the original constructor. | ||
WDYUFunctionalComponent.displayName = (0, _getDisplayName.getDisplayName)(ctor); | ||
// copy all statics from the functional component to the class | ||
// to support proptypes and context apis | ||
Object.assign(WDYUFunctionalComponent, ctor, { | ||
// our wrapper component needs an explicit display name | ||
// based on the original constructor. | ||
displayName: (0, _getDisplayName.getDisplayName)(ctor) | ||
}); | ||
return WDYUFunctionalComponent; | ||
@@ -128,6 +134,6 @@ }; | ||
// which we're going to reference in our own implementation | ||
// and which we put back when we remove `whyDidYouUpdate` from React. | ||
// and which we put back when we remove `whyDidYouUpdate` from React. | ||
var _createReactElement = React.createElement; | ||
// The memoizer is a JavaScript map that allows us to return | ||
// The memoizer is a JavaScript map that allows us to return | ||
// the same WrappedComponent for the same original constructor. | ||
@@ -138,3 +144,3 @@ // This ensure that by wrapping the constructor, we don't break | ||
// Our new implementation of `React.createElement` works by | ||
// Our new implementation of `React.createElement` works by | ||
// replacing the element constructor with a class that wraps it. | ||
@@ -153,3 +159,3 @@ React.createElement = function (type) { | ||
} else { | ||
// If the constructor function has no `render`, | ||
// If the constructor function has no `render`, | ||
// it must be a simple functioanl component. | ||
@@ -162,3 +168,3 @@ ctor = memoized(memo, ctor, function () { | ||
// Call the old `React.createElement, | ||
// Call the old `React.createElement, | ||
// but with our overwritten constructor | ||
@@ -165,0 +171,0 @@ |
{ | ||
"name": "why-did-you-update", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Patch React to discover unnecessary re-renders", | ||
@@ -39,2 +39,3 @@ "main": "lib/index.js", | ||
"prettier": "^1.15.1", | ||
"prop-types": "^15.6.2", | ||
"react": "^16.6.1", | ||
@@ -41,0 +42,0 @@ "react-dom": "^16.6.1" |
/*! | ||
* why-did-you-update v1.0.3 | ||
* why-did-you-update v1.0.4 | ||
* MIT Licensed | ||
*/ | ||
!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.WhyDidYouUpdate=t():n.WhyDidYouUpdate=t()}(window,function(){return function(n){var t={};function r(e){if(t[e])return t[e].exports;var o=t[e]={i:e,l:!1,exports:{}};return n[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=n,r.c=t,r.d=function(n,t,e){r.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:e})},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},r.t=function(n,t){if(1&t&&(n=r(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var e=Object.create(null);if(r.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var o in n)r.d(e,o,function(t){return n[t]}.bind(null,o));return e},r.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(t,"a",t),t},r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.p="",r(r.s=27)}([function(n,t){var r=Array.isArray;n.exports=r},function(n,t,r){var e=r(0),o=r(31),u=r(33),i=r(35);n.exports=function(n,t){return e(n)?n:o(n,t)?[n]:u(i(n))}},function(n,t,r){var e=r(10);n.exports=function(n,t){for(var r=n.length;r--;)if(e(n[r][0],t))return r;return-1}},function(n,t,r){var e=r(22),o=r(12),u="[object AsyncFunction]",i="[object Function]",c="[object GeneratorFunction]",f="[object Proxy]";n.exports=function(n){if(!o(n))return!1;var t=e(n);return t==i||t==c||t==u||t==f}},function(n,t){n.exports=function(n){return n}},function(n,t){n.exports=function(n){return null!=n&&"object"==typeof n}},function(n,t,r){var e=r(28),o=r(44)(function(n,t){return null==n?{}:e(n,t)});n.exports=o},function(n,t,r){var e=r(18)(Object.keys,Object);n.exports=e},function(n,t,r){var e=r(62);n.exports=function(n,t){return e(n,t)}},function(n,t){n.exports=function(n,t){for(var r=-1,e=null==n?0:n.length;++r<e;)if(t(n[r],r,n))return!0;return!1}},function(n,t){n.exports=function(n,t){return n===t||n!=n&&t!=t}},function(n,t){var r=9007199254740991,e=/^(?:0|[1-9]\d*)$/;n.exports=function(n,t){var o=typeof n;return!!(t=null==t?r:t)&&("number"==o||"symbol"!=o&&e.test(n))&&n>-1&&n%1==0&&n<t}},function(n,t){n.exports=function(n){var t=typeof n;return null!=n&&("object"==t||"function"==t)}},function(n,t){n.exports=function(){return!1}},function(n,t){var r=9007199254740991;n.exports=function(n){return"number"==typeof n&&n>-1&&n%1==0&&n<=r}},function(n,t,r){var e=r(46),o=r(47);n.exports=function n(t,r,u,i,c){var f=-1,a=t.length;for(u||(u=o),c||(c=[]);++f<a;){var p=t[f];r>0&&u(p)?r>1?n(p,r-1,u,i,c):e(c,p):i||(c[c.length]=p)}return c}},function(n,t,r){var e=r(52),o=Math.max;n.exports=function(n,t,r){return t=o(void 0===t?n.length-1:t,0),function(){for(var u=arguments,i=-1,c=o(u.length-t,0),f=Array(c);++i<c;)f[i]=u[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=u[i];return a[t]=r(f),e(n,this,a)}}},function(n,t){n.exports=function(n){return n}},function(n,t){n.exports=function(n,t){return function(r){return n(t(r))}}},function(n,t,r){var e=r(0);n.exports=function(){if(!arguments.length)return[];var n=arguments[0];return e(n)?n:[n]}},function(n,t){n.exports=function(n,t,r){for(var e=r-1,o=n.length;++e<o;)if(n[e]===t)return e;return-1}},function(n,t,r){var e=r(20);n.exports=function(n,t){return!(null==n||!n.length)&&e(n,t,0)>-1}},function(n,t){var r=Object.prototype.toString;n.exports=function(n){return r.call(n)}},function(n,t){n.exports=function(n,t){for(var r=-1,e=null==n?0:n.length;++r<e;)if(!t(n[r],r,n))return!1;return!0}},function(n,t){n.exports=function(n,t){for(var r=-1,e=null==n?0:n.length,o=0,u=[];++r<e;){var i=n[r];t(i,r,n)&&(u[o++]=i)}return u}},function(n,t,r){var e=r(15),o=r(53),u=r(55),i=r(60),c=o(function(n){return u(e(n,1,i,!0))});n.exports=c},function(n,t,r){var e=r(22),o=r(0),u=r(5),i="[object String]";n.exports=function(n){return"string"==typeof n||!o(n)&&u(n)&&e(n)==i}},function(n,t,r){n.exports=r(78)},function(n,t,r){var e=r(29),o=r(41);n.exports=function(n,t){return e(n,t,function(t,r){return o(n,r)})}},function(n,t,r){var e=r(30),o=r(36),u=r(1);n.exports=function(n,t,r){for(var i=-1,c=t.length,f={};++i<c;){var a=t[i],p=e(n,a);r(p,a)&&o(f,u(a,n),p)}return f}},function(n,t,r){var e=r(1),o=r(4);n.exports=function(n,t){for(var r=0,u=(t=e(t,n)).length;null!=n&&r<u;)n=n[o(t[r++])];return r&&r==u?n:void 0}},function(n,t,r){var e=r(0),o=r(32),u=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,i=/^\w*$/;n.exports=function(n,t){if(e(n))return!1;var r=typeof n;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=n&&!o(n))||i.test(n)||!u.test(n)||null!=t&&n in Object(t)}},function(n,t){n.exports=function(){return!1}},function(n,t,r){var e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,o=/\\(\\)?/g,u=r(34)(function(n){var t=[];return 46===n.charCodeAt(0)&&t.push(""),n.replace(e,function(n,r,e,u){t.push(e?u.replace(o,"$1"):r||n)}),t});n.exports=u},function(n,t){n.exports=function(n){return n}},function(n,t){n.exports=function(n){return n}},function(n,t,r){var e=r(37),o=r(1),u=r(11),i=r(12),c=r(4);n.exports=function(n,t,r,f){if(!i(n))return n;for(var a=-1,p=(t=o(t,n)).length,l=p-1,s=n;null!=s&&++a<p;){var v=c(t[a]),d=r;if(a!=l){var y=s[v];void 0===(d=f?f(y,v,s):void 0)&&(d=i(y)?y:u(t[a+1])?[]:{})}e(s,v,d),s=s[v]}return n}},function(n,t,r){var e=r(38),o=r(10),u=Object.prototype.hasOwnProperty;n.exports=function(n,t,r){var i=n[t];u.call(n,t)&&o(i,r)&&(void 0!==r||t in n)||e(n,t,r)}},function(n,t,r){var e=r(39);n.exports=function(n,t,r){"__proto__"==t&&e?e(n,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):n[t]=r}},function(n,t,r){var e=r(40),o=function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch(n){}}();n.exports=o},function(n,t){n.exports=function(n,t){return null==n?void 0:n[t]}},function(n,t,r){var e=r(42),o=r(43);n.exports=function(n,t){return null!=n&&o(n,t,e)}},function(n,t){n.exports=function(n,t){return null!=n&&t in Object(n)}},function(n,t,r){var e=r(1),o=r(13),u=r(0),i=r(11),c=r(14),f=r(4);n.exports=function(n,t,r){for(var a=-1,p=(t=e(t,n)).length,l=!1;++a<p;){var s=f(t[a]);if(!(l=null!=n&&r(n,s)))break;n=n[s]}return l||++a!=p?l:!!(p=null==n?0:n.length)&&c(p)&&i(s,p)&&(u(n)||o(n))}},function(n,t,r){var e=r(45),o=r(16),u=r(17);n.exports=function(n){return u(o(n,void 0,e),n+"")}},function(n,t,r){var e=r(15);n.exports=function(n){return null!=n&&n.length?e(n,1):[]}},function(n,t){n.exports=function(n,t){for(var r=-1,e=t.length,o=n.length;++r<e;)n[o+r]=t[r];return n}},function(n,t,r){var e=r(48),o=r(13),u=r(0),i=e?e.isConcatSpreadable:void 0;n.exports=function(n){return u(n)||o(n)||!!(i&&n&&n[i])}},function(n,t,r){var e=r(49).Symbol;n.exports=e},function(n,t,r){var e=r(50),o="object"==typeof self&&self&&self.Object===Object&&self,u=e||o||Function("return this")();n.exports=u},function(n,t,r){(function(t){var r="object"==typeof t&&t&&t.Object===Object&&t;n.exports=r}).call(this,r(51))},function(n,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(n){"object"==typeof window&&(r=window)}n.exports=r},function(n,t){n.exports=function(n,t,r){switch(r.length){case 0:return n.call(t);case 1:return n.call(t,r[0]);case 2:return n.call(t,r[0],r[1]);case 3:return n.call(t,r[0],r[1],r[2])}return n.apply(t,r)}},function(n,t,r){var e=r(54),o=r(16),u=r(17);n.exports=function(n,t){return u(o(n,t,e),n+"")}},function(n,t){n.exports=function(n){return n}},function(n,t,r){var e=r(19),o=r(56),u=r(57),i=r(21),c=r(58),f=r(59),a=200;n.exports=function(n,t,r){var p=-1,l=o,s=n.length,v=!0,d=[],y=d;if(r)v=!1,l=u;else if(s>=a){var x=t?null:c(n);if(x)return f(x);v=!1,l=i,y=new e}else y=t?[]:d;n:for(;++p<s;){var h=n[p],b=t?t(h):h;if(h=r||0!==h?h:0,v&&b==b){for(var g=y.length;g--;)if(y[g]===b)continue n;t&&y.push(b),d.push(h)}else l(y,b,r)||(y!==d&&y.push(b),d.push(h))}return d}},function(n,t,r){var e=r(20);n.exports=function(n,t){return!(null==n||!n.length)&&e(n,t,0)>-1}},function(n,t){n.exports=function(n,t,r){for(var e=-1,o=null==n?0:n.length;++e<o;)if(r(t,n[e]))return!0;return!1}},function(n,t){n.exports=function(){}},function(n,t){n.exports=function(){return[]}},function(n,t,r){var e=r(61),o=r(5);n.exports=function(n){return o(n)&&e(n)}},function(n,t,r){var e=r(3),o=r(14);n.exports=function(n){return null!=n&&o(n.length)&&!e(n)}},function(n,t,r){var e=r(63),o=r(5);n.exports=function n(t,r,u,i,c){return t===r||(null==t||null==r||!o(t)&&!o(r)?t!=t&&r!=r:e(t,r,u,i,n,c))}},function(n,t,r){var e=r(64),o=r(70),u=r(72),i=r(73),c=r(75),f=r(0),a=r(76),p=r(77),l=1,s="[object Arguments]",v="[object Array]",d="[object Object]",y=Object.prototype.hasOwnProperty;n.exports=function(n,t,r,x,h,b){var g=f(n),_=f(t),m=g?v:c(n),j=_?v:c(t),O=(m=m==s?d:m)==d,w=(j=j==s?d:j)==d,A=m==j;if(A&&a(n)){if(!a(t))return!1;g=!0,O=!1}if(A&&!O)return b||(b=new e),g||p(n)?o(n,t,r,x,h,b):u(n,t,m,r,x,h,b);if(!(r&l)){var E=O&&y.call(n,"__wrapped__"),U=w&&y.call(t,"__wrapped__");if(E||U){var S=E?n.value():n,D=U?t.value():t;return b||(b=new e),h(S,D,r,x,b)}}return!!A&&(b||(b=new e),i(n,t,r,x,h,b))}},function(n,t,r){var e=r(65),o=r(66),u=r(67),i=r(68),c=r(69);function f(n){var t=-1,r=null==n?0:n.length;for(this.clear();++t<r;){var e=n[t];this.set(e[0],e[1])}}f.prototype.clear=e,f.prototype.delete=o,f.prototype.get=u,f.prototype.has=i,f.prototype.set=c,n.exports=f},function(n,t){n.exports=function(){this.__data__=[],this.size=0}},function(n,t,r){var e=r(2),o=Array.prototype.splice;n.exports=function(n){var t=this.__data__,r=e(t,n);return!(r<0||(r==t.length-1?t.pop():o.call(t,r,1),--this.size,0))}},function(n,t,r){var e=r(2);n.exports=function(n){var t=this.__data__,r=e(t,n);return r<0?void 0:t[r][1]}},function(n,t,r){var e=r(2);n.exports=function(n){return e(this.__data__,n)>-1}},function(n,t,r){var e=r(2);n.exports=function(n,t){var r=this.__data__,o=e(r,n);return o<0?(++this.size,r.push([n,t])):r[o][1]=t,this}},function(n,t,r){var e=r(19),o=r(71),u=r(21),i=1,c=2;n.exports=function(n,t,r,f,a,p){var l=r&i,s=n.length,v=t.length;if(s!=v&&!(l&&v>s))return!1;var d=p.get(n);if(d&&p.get(t))return d==t;var y=-1,x=!0,h=r&c?new e:void 0;for(p.set(n,t),p.set(t,n);++y<s;){var b=n[y],g=t[y];if(f)var _=l?f(g,b,y,t,n,p):f(b,g,y,n,t,p);if(void 0!==_){if(_)continue;x=!1;break}if(h){if(!o(t,function(n,t){if(!u(h,t)&&(b===n||a(b,n,r,f,p)))return h.push(t)})){x=!1;break}}else if(b!==g&&!a(b,g,r,f,p)){x=!1;break}}return p.delete(n),p.delete(t),x}},function(n,t){n.exports=function(n,t){for(var r=-1,e=null==n?0:n.length;++r<e;)if(t(n[r],r,n))return!0;return!1}},function(n,t){n.exports=function(n,t){return n===t||n!=n&&t!=t}},function(n,t,r){var e=r(74),o=1,u=Object.prototype.hasOwnProperty;n.exports=function(n,t,r,i,c,f){var a=r&o,p=e(n),l=p.length;if(l!=e(t).length&&!a)return!1;for(var s=l;s--;){var v=p[s];if(!(a?v in t:u.call(t,v)))return!1}var d=f.get(n);if(d&&f.get(t))return d==t;var y=!0;f.set(n,t),f.set(t,n);for(var x=a;++s<l;){var h=n[v=p[s]],b=t[v];if(i)var g=a?i(b,h,v,t,n,f):i(h,b,v,n,t,f);if(!(void 0===g?h===b||c(h,b,r,i,f):g)){y=!1;break}x||(x="constructor"==v)}if(y&&!x){var _=n.constructor,m=t.constructor;_!=m&&"constructor"in n&&"constructor"in t&&!("function"==typeof _&&_ instanceof _&&"function"==typeof m&&m instanceof m)&&(y=!1)}return f.delete(n),f.delete(t),y}},function(n,t,r){var e=r(18)(Object.keys,Object);n.exports=e},function(n,t){var r=Object.prototype.toString;n.exports=function(n){return r.call(n)}},function(n,t){n.exports=function(){return!1}},function(n,t){n.exports=function(){return!1}},function(n,t,r){"use strict";r.r(t);var e=r(6),o=r.n(e),u=r(23),i=r.n(u),c=r(24),f=r.n(c),a=r(7),p=r.n(a),l=r(25),s=r.n(l),v=r(3),d=r.n(v),y=r(8),x=r.n(y),h={UNAVOIDABLE:"unavoidable",SAME:"same",EQUAL:"equal",FUNCTIONS:"functions"},b=function(n,t,r){if(n===t)return{type:h.SAME,name:r,prev:n,next:t};if(x()(n,t))return{type:h.EQUAL,name:r,prev:n,next:t};if(!n||!t)return{type:h.UNAVOIDABLE,name:r,prev:n,next:t};var e=s()(p()(n),p()(t)),u=f()(e,function(r){return n[r]!==t[r]&&!x()(n[r],t[r])});return u.length&&i()(u,function(r){var e=n[r],o=t[r];return d()(e)&&d()(o)&&e.name===o.name})?{type:h.FUNCTIONS,name:r,prev:o()(n,u),next:o()(t,u)}:{type:h.UNAVOIDABLE,name:r,prev:n,next:t}},g=function(n){return n.displayName||n.name},_=r(26),m=r.n(_),j=function(n,t,r,e){n&&t?console.groupCollapsed&&console.groupCollapsed(r):n&&console.group&&console.group(r),e.forEach(w),n&&console.groupEnd&&console.groupEnd()},O=function(n){var t=console.disableYellowBox;console.disableYellowBox=!0,console.warn(n),console.disableYellowBox=t},w=function(n){var t=n.name,r=n.prev,e=n.next;switch(n.type){case h.SAME:O(t+": Value is the same (equal by reference). Avoidable re-render!"),console.log("Value:",r);break;case h.EQUAL:O(t+": Value did not change. Avoidable re-render!"),console.log("Before:",r),console.log("After:",e),r&&e&&Object.keys(r).forEach(function(n){r[n]!==e[n]&&console.log('"'+n+'" property is not equal by reference')});break;case h.FUNCTIONS:O(t+": Changes are in functions only. Possibly avoidable re-render?"),console.log("Functions before:",r),console.log("Functions after:",e)}},A=/./,E=/[^a-zA-Z0-9()]/,U=function(n){return m()(n)?new RegExp("^"+n+"$"):n},S=function(n){return n?[].concat(n):[]},D=r(9),C=r.n(D),N=function(n,t){var r=t.include,e=t.exclude;return C()(r,function(t){return t.test(n)})&&!C()(e,function(t){return t.test(n)})};function P(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}function B(n,t){if(!n)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?n:t}function F(n,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(n,t):n.__proto__=t)}r.d(t,"whyDidYouUpdate",function(){return I});var T=function(n,t,r){if(n.has(t))return n.get(t);var e=r();return n.set(t,e),e};function k(n){return function(t,r){var e=g(this.constructor);if(N(e,n)){var o=b(t,this.props,e+".props");if(o.type!==h.UNAVOIDABLE){var u=b(r,this.state,e+".state");u.type!==h.UNAVOIDABLE&&n.notifier(n.groupByComponent,n.collapseComponentGroups,e,[o,u])}}}}var I=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=n.include,r=void 0===t?[A]:t,e=n.exclude,o=void 0===e?[E]:e,u=n.groupByComponent,i=void 0===u||u,c=n.collapseComponentGroups,f=void 0===c||c,a=n.notifier;return{notifier:void 0===a?j:a,include:S(r).map(U),exclude:S(o).map(U),groupByComponent:i,collapseComponentGroups:f}}(t);var r=n.createElement,e=new Map;return n.createElement=function(o){var u=o;"function"==typeof u&&(u=u.prototype&&"function"==typeof u.prototype.render?T(e,u,function(){return function(n,t){var r=k(t),e=function(t){function e(){return P(this,e),B(this,t.apply(this,arguments))}return F(e,t),e.prototype.componentDidUpdate=function(t,e,o){r.call(this,t,e),"function"==typeof n.prototype.componentDidUpdate&&n.prototype.componentDidUpdate.call(this,t,e,o)},e}(n);return e.displayName=g(n),e}(u,t)}):T(e,u,function(){return function(n,t,r){var e=k(t),o=function(t){function r(){return P(this,r),B(this,t.apply(this,arguments))}return F(r,t),r.prototype.render=function(){return n(this.props)},r.prototype.componentDidUpdate=function(n,t,r){e.call(this,n,t,r)},r}(r);return o.displayName=g(n),o}(u,t,n.Component)}));for(var i=arguments.length,c=Array(i>1?i-1:0),f=1;f<i;f++)c[f-1]=arguments[f];return r.apply(n,[u].concat(c))},n.__WHY_DID_YOU_UPDATE_RESTORE_FN__=function(){n.createElement=r,delete n.__WHY_DID_YOU_UPDATE_RESTORE_FN__},n};t.default=I}]).default}); | ||
!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.WhyDidYouUpdate=t():n.WhyDidYouUpdate=t()}(window,function(){return function(n){var t={};function r(e){if(t[e])return t[e].exports;var o=t[e]={i:e,l:!1,exports:{}};return n[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=n,r.c=t,r.d=function(n,t,e){r.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:e})},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},r.t=function(n,t){if(1&t&&(n=r(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var e=Object.create(null);if(r.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var o in n)r.d(e,o,function(t){return n[t]}.bind(null,o));return e},r.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(t,"a",t),t},r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.p="",r(r.s=27)}([function(n,t){var r=Array.isArray;n.exports=r},function(n,t,r){var e=r(0),o=r(31),u=r(33),i=r(35);n.exports=function(n,t){return e(n)?n:o(n,t)?[n]:u(i(n))}},function(n,t,r){var e=r(10);n.exports=function(n,t){for(var r=n.length;r--;)if(e(n[r][0],t))return r;return-1}},function(n,t,r){var e=r(22),o=r(12),u="[object AsyncFunction]",i="[object Function]",c="[object GeneratorFunction]",f="[object Proxy]";n.exports=function(n){if(!o(n))return!1;var t=e(n);return t==i||t==c||t==u||t==f}},function(n,t){n.exports=function(n){return n}},function(n,t){n.exports=function(n){return null!=n&&"object"==typeof n}},function(n,t,r){var e=r(28),o=r(44)(function(n,t){return null==n?{}:e(n,t)});n.exports=o},function(n,t,r){var e=r(18)(Object.keys,Object);n.exports=e},function(n,t,r){var e=r(62);n.exports=function(n,t){return e(n,t)}},function(n,t){n.exports=function(n,t){for(var r=-1,e=null==n?0:n.length;++r<e;)if(t(n[r],r,n))return!0;return!1}},function(n,t){n.exports=function(n,t){return n===t||n!=n&&t!=t}},function(n,t){var r=9007199254740991,e=/^(?:0|[1-9]\d*)$/;n.exports=function(n,t){var o=typeof n;return!!(t=null==t?r:t)&&("number"==o||"symbol"!=o&&e.test(n))&&n>-1&&n%1==0&&n<t}},function(n,t){n.exports=function(n){var t=typeof n;return null!=n&&("object"==t||"function"==t)}},function(n,t){n.exports=function(){return!1}},function(n,t){var r=9007199254740991;n.exports=function(n){return"number"==typeof n&&n>-1&&n%1==0&&n<=r}},function(n,t,r){var e=r(46),o=r(47);n.exports=function n(t,r,u,i,c){var f=-1,a=t.length;for(u||(u=o),c||(c=[]);++f<a;){var p=t[f];r>0&&u(p)?r>1?n(p,r-1,u,i,c):e(c,p):i||(c[c.length]=p)}return c}},function(n,t,r){var e=r(52),o=Math.max;n.exports=function(n,t,r){return t=o(void 0===t?n.length-1:t,0),function(){for(var u=arguments,i=-1,c=o(u.length-t,0),f=Array(c);++i<c;)f[i]=u[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=u[i];return a[t]=r(f),e(n,this,a)}}},function(n,t){n.exports=function(n){return n}},function(n,t){n.exports=function(n,t){return function(r){return n(t(r))}}},function(n,t,r){var e=r(0);n.exports=function(){if(!arguments.length)return[];var n=arguments[0];return e(n)?n:[n]}},function(n,t){n.exports=function(n,t,r){for(var e=r-1,o=n.length;++e<o;)if(n[e]===t)return e;return-1}},function(n,t,r){var e=r(20);n.exports=function(n,t){return!(null==n||!n.length)&&e(n,t,0)>-1}},function(n,t){var r=Object.prototype.toString;n.exports=function(n){return r.call(n)}},function(n,t){n.exports=function(n,t){for(var r=-1,e=null==n?0:n.length;++r<e;)if(!t(n[r],r,n))return!1;return!0}},function(n,t){n.exports=function(n,t){for(var r=-1,e=null==n?0:n.length,o=0,u=[];++r<e;){var i=n[r];t(i,r,n)&&(u[o++]=i)}return u}},function(n,t,r){var e=r(15),o=r(53),u=r(55),i=r(60),c=o(function(n){return u(e(n,1,i,!0))});n.exports=c},function(n,t,r){var e=r(22),o=r(0),u=r(5),i="[object String]";n.exports=function(n){return"string"==typeof n||!o(n)&&u(n)&&e(n)==i}},function(n,t,r){n.exports=r(78)},function(n,t,r){var e=r(29),o=r(41);n.exports=function(n,t){return e(n,t,function(t,r){return o(n,r)})}},function(n,t,r){var e=r(30),o=r(36),u=r(1);n.exports=function(n,t,r){for(var i=-1,c=t.length,f={};++i<c;){var a=t[i],p=e(n,a);r(p,a)&&o(f,u(a,n),p)}return f}},function(n,t,r){var e=r(1),o=r(4);n.exports=function(n,t){for(var r=0,u=(t=e(t,n)).length;null!=n&&r<u;)n=n[o(t[r++])];return r&&r==u?n:void 0}},function(n,t,r){var e=r(0),o=r(32),u=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,i=/^\w*$/;n.exports=function(n,t){if(e(n))return!1;var r=typeof n;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=n&&!o(n))||i.test(n)||!u.test(n)||null!=t&&n in Object(t)}},function(n,t){n.exports=function(){return!1}},function(n,t,r){var e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,o=/\\(\\)?/g,u=r(34)(function(n){var t=[];return 46===n.charCodeAt(0)&&t.push(""),n.replace(e,function(n,r,e,u){t.push(e?u.replace(o,"$1"):r||n)}),t});n.exports=u},function(n,t){n.exports=function(n){return n}},function(n,t){n.exports=function(n){return n}},function(n,t,r){var e=r(37),o=r(1),u=r(11),i=r(12),c=r(4);n.exports=function(n,t,r,f){if(!i(n))return n;for(var a=-1,p=(t=o(t,n)).length,l=p-1,s=n;null!=s&&++a<p;){var v=c(t[a]),d=r;if(a!=l){var y=s[v];void 0===(d=f?f(y,v,s):void 0)&&(d=i(y)?y:u(t[a+1])?[]:{})}e(s,v,d),s=s[v]}return n}},function(n,t,r){var e=r(38),o=r(10),u=Object.prototype.hasOwnProperty;n.exports=function(n,t,r){var i=n[t];u.call(n,t)&&o(i,r)&&(void 0!==r||t in n)||e(n,t,r)}},function(n,t,r){var e=r(39);n.exports=function(n,t,r){"__proto__"==t&&e?e(n,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):n[t]=r}},function(n,t,r){var e=r(40),o=function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch(n){}}();n.exports=o},function(n,t){n.exports=function(n,t){return null==n?void 0:n[t]}},function(n,t,r){var e=r(42),o=r(43);n.exports=function(n,t){return null!=n&&o(n,t,e)}},function(n,t){n.exports=function(n,t){return null!=n&&t in Object(n)}},function(n,t,r){var e=r(1),o=r(13),u=r(0),i=r(11),c=r(14),f=r(4);n.exports=function(n,t,r){for(var a=-1,p=(t=e(t,n)).length,l=!1;++a<p;){var s=f(t[a]);if(!(l=null!=n&&r(n,s)))break;n=n[s]}return l||++a!=p?l:!!(p=null==n?0:n.length)&&c(p)&&i(s,p)&&(u(n)||o(n))}},function(n,t,r){var e=r(45),o=r(16),u=r(17);n.exports=function(n){return u(o(n,void 0,e),n+"")}},function(n,t,r){var e=r(15);n.exports=function(n){return null!=n&&n.length?e(n,1):[]}},function(n,t){n.exports=function(n,t){for(var r=-1,e=t.length,o=n.length;++r<e;)n[o+r]=t[r];return n}},function(n,t,r){var e=r(48),o=r(13),u=r(0),i=e?e.isConcatSpreadable:void 0;n.exports=function(n){return u(n)||o(n)||!!(i&&n&&n[i])}},function(n,t,r){var e=r(49).Symbol;n.exports=e},function(n,t,r){var e=r(50),o="object"==typeof self&&self&&self.Object===Object&&self,u=e||o||Function("return this")();n.exports=u},function(n,t,r){(function(t){var r="object"==typeof t&&t&&t.Object===Object&&t;n.exports=r}).call(this,r(51))},function(n,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(n){"object"==typeof window&&(r=window)}n.exports=r},function(n,t){n.exports=function(n,t,r){switch(r.length){case 0:return n.call(t);case 1:return n.call(t,r[0]);case 2:return n.call(t,r[0],r[1]);case 3:return n.call(t,r[0],r[1],r[2])}return n.apply(t,r)}},function(n,t,r){var e=r(54),o=r(16),u=r(17);n.exports=function(n,t){return u(o(n,t,e),n+"")}},function(n,t){n.exports=function(n){return n}},function(n,t,r){var e=r(19),o=r(56),u=r(57),i=r(21),c=r(58),f=r(59),a=200;n.exports=function(n,t,r){var p=-1,l=o,s=n.length,v=!0,d=[],y=d;if(r)v=!1,l=u;else if(s>=a){var x=t?null:c(n);if(x)return f(x);v=!1,l=i,y=new e}else y=t?[]:d;n:for(;++p<s;){var h=n[p],b=t?t(h):h;if(h=r||0!==h?h:0,v&&b==b){for(var g=y.length;g--;)if(y[g]===b)continue n;t&&y.push(b),d.push(h)}else l(y,b,r)||(y!==d&&y.push(b),d.push(h))}return d}},function(n,t,r){var e=r(20);n.exports=function(n,t){return!(null==n||!n.length)&&e(n,t,0)>-1}},function(n,t){n.exports=function(n,t,r){for(var e=-1,o=null==n?0:n.length;++e<o;)if(r(t,n[e]))return!0;return!1}},function(n,t){n.exports=function(){}},function(n,t){n.exports=function(){return[]}},function(n,t,r){var e=r(61),o=r(5);n.exports=function(n){return o(n)&&e(n)}},function(n,t,r){var e=r(3),o=r(14);n.exports=function(n){return null!=n&&o(n.length)&&!e(n)}},function(n,t,r){var e=r(63),o=r(5);n.exports=function n(t,r,u,i,c){return t===r||(null==t||null==r||!o(t)&&!o(r)?t!=t&&r!=r:e(t,r,u,i,n,c))}},function(n,t,r){var e=r(64),o=r(70),u=r(72),i=r(73),c=r(75),f=r(0),a=r(76),p=r(77),l=1,s="[object Arguments]",v="[object Array]",d="[object Object]",y=Object.prototype.hasOwnProperty;n.exports=function(n,t,r,x,h,b){var g=f(n),_=f(t),m=g?v:c(n),j=_?v:c(t),O=(m=m==s?d:m)==d,w=(j=j==s?d:j)==d,A=m==j;if(A&&a(n)){if(!a(t))return!1;g=!0,O=!1}if(A&&!O)return b||(b=new e),g||p(n)?o(n,t,r,x,h,b):u(n,t,m,r,x,h,b);if(!(r&l)){var E=O&&y.call(n,"__wrapped__"),U=w&&y.call(t,"__wrapped__");if(E||U){var S=E?n.value():n,D=U?t.value():t;return b||(b=new e),h(S,D,r,x,b)}}return!!A&&(b||(b=new e),i(n,t,r,x,h,b))}},function(n,t,r){var e=r(65),o=r(66),u=r(67),i=r(68),c=r(69);function f(n){var t=-1,r=null==n?0:n.length;for(this.clear();++t<r;){var e=n[t];this.set(e[0],e[1])}}f.prototype.clear=e,f.prototype.delete=o,f.prototype.get=u,f.prototype.has=i,f.prototype.set=c,n.exports=f},function(n,t){n.exports=function(){this.__data__=[],this.size=0}},function(n,t,r){var e=r(2),o=Array.prototype.splice;n.exports=function(n){var t=this.__data__,r=e(t,n);return!(r<0||(r==t.length-1?t.pop():o.call(t,r,1),--this.size,0))}},function(n,t,r){var e=r(2);n.exports=function(n){var t=this.__data__,r=e(t,n);return r<0?void 0:t[r][1]}},function(n,t,r){var e=r(2);n.exports=function(n){return e(this.__data__,n)>-1}},function(n,t,r){var e=r(2);n.exports=function(n,t){var r=this.__data__,o=e(r,n);return o<0?(++this.size,r.push([n,t])):r[o][1]=t,this}},function(n,t,r){var e=r(19),o=r(71),u=r(21),i=1,c=2;n.exports=function(n,t,r,f,a,p){var l=r&i,s=n.length,v=t.length;if(s!=v&&!(l&&v>s))return!1;var d=p.get(n);if(d&&p.get(t))return d==t;var y=-1,x=!0,h=r&c?new e:void 0;for(p.set(n,t),p.set(t,n);++y<s;){var b=n[y],g=t[y];if(f)var _=l?f(g,b,y,t,n,p):f(b,g,y,n,t,p);if(void 0!==_){if(_)continue;x=!1;break}if(h){if(!o(t,function(n,t){if(!u(h,t)&&(b===n||a(b,n,r,f,p)))return h.push(t)})){x=!1;break}}else if(b!==g&&!a(b,g,r,f,p)){x=!1;break}}return p.delete(n),p.delete(t),x}},function(n,t){n.exports=function(n,t){for(var r=-1,e=null==n?0:n.length;++r<e;)if(t(n[r],r,n))return!0;return!1}},function(n,t){n.exports=function(n,t){return n===t||n!=n&&t!=t}},function(n,t,r){var e=r(74),o=1,u=Object.prototype.hasOwnProperty;n.exports=function(n,t,r,i,c,f){var a=r&o,p=e(n),l=p.length;if(l!=e(t).length&&!a)return!1;for(var s=l;s--;){var v=p[s];if(!(a?v in t:u.call(t,v)))return!1}var d=f.get(n);if(d&&f.get(t))return d==t;var y=!0;f.set(n,t),f.set(t,n);for(var x=a;++s<l;){var h=n[v=p[s]],b=t[v];if(i)var g=a?i(b,h,v,t,n,f):i(h,b,v,n,t,f);if(!(void 0===g?h===b||c(h,b,r,i,f):g)){y=!1;break}x||(x="constructor"==v)}if(y&&!x){var _=n.constructor,m=t.constructor;_!=m&&"constructor"in n&&"constructor"in t&&!("function"==typeof _&&_ instanceof _&&"function"==typeof m&&m instanceof m)&&(y=!1)}return f.delete(n),f.delete(t),y}},function(n,t,r){var e=r(18)(Object.keys,Object);n.exports=e},function(n,t){var r=Object.prototype.toString;n.exports=function(n){return r.call(n)}},function(n,t){n.exports=function(){return!1}},function(n,t){n.exports=function(){return!1}},function(n,t,r){"use strict";r.r(t);var e=r(6),o=r.n(e),u=r(23),i=r.n(u),c=r(24),f=r.n(c),a=r(7),p=r.n(a),l=r(25),s=r.n(l),v=r(3),d=r.n(v),y=r(8),x=r.n(y),h={UNAVOIDABLE:"unavoidable",SAME:"same",EQUAL:"equal",FUNCTIONS:"functions"},b=function(n,t,r){if(n===t)return{type:h.SAME,name:r,prev:n,next:t};if(x()(n,t))return{type:h.EQUAL,name:r,prev:n,next:t};if(!n||!t)return{type:h.UNAVOIDABLE,name:r,prev:n,next:t};var e=s()(p()(n),p()(t)),u=f()(e,function(r){return n[r]!==t[r]&&!x()(n[r],t[r])});return u.length&&i()(u,function(r){var e=n[r],o=t[r];return d()(e)&&d()(o)&&e.name===o.name})?{type:h.FUNCTIONS,name:r,prev:o()(n,u),next:o()(t,u)}:{type:h.UNAVOIDABLE,name:r,prev:n,next:t}},g=function(n){return n.displayName||n.name},_=r(26),m=r.n(_),j=function(n,t,r,e){n&&t?console.groupCollapsed&&console.groupCollapsed(r):n&&console.group&&console.group(r),e.forEach(w),n&&console.groupEnd&&console.groupEnd()},O=function(n){var t=console.disableYellowBox;console.disableYellowBox=!0,console.warn(n),console.disableYellowBox=t},w=function(n){var t=n.name,r=n.prev,e=n.next;switch(n.type){case h.SAME:O(t+": Value is the same (equal by reference). Avoidable re-render!"),console.log("Value:",r);break;case h.EQUAL:O(t+": Value did not change. Avoidable re-render!"),console.log("Before:",r),console.log("After:",e),r&&e&&Object.keys(r).forEach(function(n){r[n]!==e[n]&&console.log('"'+n+'" property is not equal by reference')});break;case h.FUNCTIONS:O(t+": Changes are in functions only. Possibly avoidable re-render?"),console.log("Functions before:",r),console.log("Functions after:",e)}},A=/./,E=/[^a-zA-Z0-9()]/,U=function(n){return m()(n)?new RegExp("^"+n+"$"):n},S=function(n){return n?[].concat(n):[]},D=r(9),C=r.n(D),N=function(n,t){var r=t.include,e=t.exclude;return C()(r,function(t){return t.test(n)})&&!C()(e,function(t){return t.test(n)})};function P(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}function B(n,t){if(!n)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?n:t}function F(n,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(n,t):n.__proto__=t)}r.d(t,"whyDidYouUpdate",function(){return I});var T=function(n,t,r){if(n.has(t))return n.get(t);var e=r();return n.set(t,e),e};function k(n){return function(t,r){var e=g(this.constructor);if(N(e,n)){var o=b(t,this.props,e+".props");if(o.type!==h.UNAVOIDABLE){var u=b(r,this.state,e+".state");u.type!==h.UNAVOIDABLE&&n.notifier(n.groupByComponent,n.collapseComponentGroups,e,[o,u])}}}}var I=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=n.include,r=void 0===t?[A]:t,e=n.exclude,o=void 0===e?[E]:e,u=n.groupByComponent,i=void 0===u||u,c=n.collapseComponentGroups,f=void 0===c||c,a=n.notifier;return{notifier:void 0===a?j:a,include:S(r).map(U),exclude:S(o).map(U),groupByComponent:i,collapseComponentGroups:f}}(t);var r=n.createElement,e=new Map;return n.createElement=function(o){var u=o;"function"==typeof u&&(u=u.prototype&&"function"==typeof u.prototype.render?T(e,u,function(){return function(n,t){var r=k(t),e=function(t){function e(){return P(this,e),B(this,t.apply(this,arguments))}return F(e,t),e.prototype.componentDidUpdate=function(t,e,o){r.call(this,t,e),"function"==typeof n.prototype.componentDidUpdate&&n.prototype.componentDidUpdate.call(this,t,e,o)},e}(n);return e.displayName=g(n),e}(u,t)}):T(e,u,function(){return function(n,t,r){var e=k(t),o=function(t){function r(){return P(this,r),B(this,t.apply(this,arguments))}return F(r,t),r.prototype.render=function(){return n(this.props,this.context)},r.prototype.componentDidUpdate=function(n,t,r){e.call(this,n,t,r)},r}(r);return Object.assign(o,n,{displayName:g(n)}),o}(u,t,n.Component)}));for(var i=arguments.length,c=Array(i>1?i-1:0),f=1;f<i;f++)c[f-1]=arguments[f];return r.apply(n,[u].concat(c))},n.__WHY_DID_YOU_UPDATE_RESTORE_FN__=function(){n.createElement=r,delete n.__WHY_DID_YOU_UPDATE_RESTORE_FN__},n};t.default=I}]).default}); | ||
//# sourceMappingURL=why-did-you-update.min.js.map |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
222375
3186
15