Skip to content

Commit

Permalink
v4.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
vzaidman committed May 30, 2020
1 parent 5b85841 commit ddaf0e8
Show file tree
Hide file tree
Showing 19 changed files with 448 additions and 238 deletions.
109 changes: 72 additions & 37 deletions dist/cjs/whyDidYouRender.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* @welldone-software/why-did-you-render 4.2.2
* @welldone-software/why-did-you-render 4.2.3
* MIT Licensed
* Generated by Vitali Zaidman <vzaidman@gmail.com> (https://github.com/vzaidman)
* Generated at 2020-05-20
* Generated at 2020-05-30
*/

'use strict';
Expand Down Expand Up @@ -156,7 +156,7 @@ function _possibleConstructorReturn(self, call) {
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();

return function () {
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived),
result;

Expand Down Expand Up @@ -274,9 +274,12 @@ function _nonIterableRest() {
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 _createForOfIteratorHelper(o) {
function _createForOfIteratorHelper(o, allowArrayLike) {
var it;

if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;

var F = function () {};
Expand All @@ -302,8 +305,7 @@ function _createForOfIteratorHelper(o) {
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}

var it,
normalCompletion = true,
var normalCompletion = true,
didErr = false,
err;
return {
Expand Down Expand Up @@ -782,6 +784,31 @@ function findObjectsDifferences(userPrevObj, userNextObj) {
}, []);
}

function getOwnerDifferences(_ref) {
var prevOwnerData = _ref.prevOwnerData,
nextOwnerData = _ref.nextOwnerData;

if (!prevOwnerData || !nextOwnerData) {
return false;
}

var hookDifferences = prevOwnerData.hooks.map(function (_ref2, i) {
var hookName = _ref2.hookName,
result = _ref2.result;
return {
hookName: hookName,
differences: findObjectsDifferences(result, nextOwnerData.hooks[i].result, {
shallow: false
})
};
});
return {
propsDifferences: findObjectsDifferences(prevOwnerData.props, nextOwnerData.props),
stateDifferences: findObjectsDifferences(prevOwnerData.state, nextOwnerData.state),
hookDifferences: hookDifferences.length > 0 ? hookDifferences : false
};
}

function getUpdateReason(prevProps, prevState, prevHook, nextProps, nextState, nextHook, ownerDataMap) {
var prevOwnerData = ownerDataMap.get(prevProps);
var nextOwnerData = ownerDataMap.get(nextProps);
Expand All @@ -791,35 +818,25 @@ function getUpdateReason(prevProps, prevState, prevHook, nextProps, nextState, n
hookDifferences: findObjectsDifferences(prevHook, nextHook, {
shallow: false
}),
ownerDifferences: prevOwnerData != null && nextOwnerData != null ? {
propsDifferences: findObjectsDifferences(prevOwnerData.props, nextOwnerData.props),
stateDifferences: findObjectsDifferences(prevOwnerData.state, nextOwnerData.state),
hookDifferences: prevOwnerData.hooks.map(function (_ref, i) {
var hookName = _ref.hookName,
result = _ref.result;
return {
hookName: hookName,
differences: findObjectsDifferences(result, nextOwnerData.hooks[i].result, {
shallow: false
})
};
})
} : false
ownerDifferences: getOwnerDifferences({
prevOwnerData: prevOwnerData,
nextOwnerData: nextOwnerData
})
};
}

function getUpdateInfo(_ref2) {
var Component = _ref2.Component,
displayName = _ref2.displayName,
hookName = _ref2.hookName,
prevProps = _ref2.prevProps,
prevState = _ref2.prevState,
prevHook = _ref2.prevHook,
nextProps = _ref2.nextProps,
nextState = _ref2.nextState,
nextHook = _ref2.nextHook,
options = _ref2.options,
ownerDataMap = _ref2.ownerDataMap;
function getUpdateInfo(_ref3) {
var Component = _ref3.Component,
displayName = _ref3.displayName,
hookName = _ref3.hookName,
prevProps = _ref3.prevProps,
prevState = _ref3.prevState,
prevHook = _ref3.prevHook,
nextProps = _ref3.nextProps,
nextState = _ref3.nextState,
nextHook = _ref3.nextHook,
options = _ref3.options,
ownerDataMap = _ref3.ownerDataMap;
return {
Component: Component,
displayName: displayName,
Expand Down Expand Up @@ -904,7 +921,7 @@ function patchClassComponent(ClassComponent, displayName, React, options, ownerD
var _super = _createSuper(WDYRPatchedClassComponent);

function WDYRPatchedClassComponent(props, context) {
var _this;
var _thisSuper, _this;

_classCallCheck(this, WDYRPatchedClassComponent);

Expand All @@ -913,7 +930,7 @@ function patchClassComponent(ClassComponent, displayName, React, options, ownerD
renderNumber: 0
};

var origRender = _get(_getPrototypeOf(WDYRPatchedClassComponent.prototype), "render", _assertThisInitialized(_this)) || _this.render; // this probably means render is an arrow function or this.render.bind(this) was called on the original class
var origRender = _get((_thisSuper = _assertThisInitialized(_this), _getPrototypeOf(WDYRPatchedClassComponent.prototype)), "render", _thisSuper) || _this.render; // this probably means render is an arrow function or this.render.bind(this) was called on the original class


var renderIsABindedFunction = origRender !== ClassComponent.prototype.render;
Expand Down Expand Up @@ -1149,6 +1166,24 @@ function getPatchedComponent(componentsMap, Component, displayName, React, optio
return WDYRPatchedComponent;
}

function getIsSupportedComponentType(Comp) {
if (!Comp) {
return false;
}

if (typeof Comp === 'function') {
return true;
}

if (isMemoComponent(Comp)) {
return getIsSupportedComponentType(Comp.type);
}

if (isForwardRefComponent(Comp)) {
return getIsSupportedComponentType(Comp.render);
}
}

var hooksConfig = {
useState: {
path: '0'
Expand Down Expand Up @@ -1193,7 +1228,7 @@ function whyDidYouRender(React, userOptions) {
}

try {
isShouldTrack = (typeof componentNameOrComponent === 'function' || isMemoComponent(componentNameOrComponent) || isForwardRefComponent(componentNameOrComponent)) && shouldTrack({
isShouldTrack = getIsSupportedComponentType(componentNameOrComponent) && shouldTrack({
Component: componentNameOrComponent,
displayName: getDisplayName(componentNameOrComponent),
React: React,
Expand All @@ -1208,7 +1243,7 @@ function whyDidYouRender(React, userOptions) {
if (options.logOwnerReasons) {
var OwnerInstance = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner.current;

if (OwnerInstance != null) {
if (OwnerInstance) {
var Component = OwnerInstance.type.ComponentForHooksTracking || OwnerInstance.type;

var _displayName = getDisplayName(Component);
Expand Down
6 changes: 3 additions & 3 deletions dist/cjs/whyDidYouRender.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cjs/whyDidYouRender.min.js.map

Large diffs are not rendered by default.

109 changes: 72 additions & 37 deletions dist/esm/whyDidYouRender.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* @welldone-software/why-did-you-render 4.2.2
* @welldone-software/why-did-you-render 4.2.3
* MIT Licensed
* Generated by Vitali Zaidman <vzaidman@gmail.com> (https://github.com/vzaidman)
* Generated at 2020-05-20
* Generated at 2020-05-30
*/

import _get$1 from 'lodash/get';
Expand Down Expand Up @@ -152,7 +152,7 @@ function _possibleConstructorReturn(self, call) {
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();

return function () {
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived),
result;

Expand Down Expand Up @@ -270,9 +270,12 @@ function _nonIterableRest() {
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 _createForOfIteratorHelper(o) {
function _createForOfIteratorHelper(o, allowArrayLike) {
var it;

if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;

var F = function () {};
Expand All @@ -298,8 +301,7 @@ function _createForOfIteratorHelper(o) {
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}

var it,
normalCompletion = true,
var normalCompletion = true,
didErr = false,
err;
return {
Expand Down Expand Up @@ -778,6 +780,31 @@ function findObjectsDifferences(userPrevObj, userNextObj) {
}, []);
}

function getOwnerDifferences(_ref) {
var prevOwnerData = _ref.prevOwnerData,
nextOwnerData = _ref.nextOwnerData;

if (!prevOwnerData || !nextOwnerData) {
return false;
}

var hookDifferences = prevOwnerData.hooks.map(function (_ref2, i) {
var hookName = _ref2.hookName,
result = _ref2.result;
return {
hookName: hookName,
differences: findObjectsDifferences(result, nextOwnerData.hooks[i].result, {
shallow: false
})
};
});
return {
propsDifferences: findObjectsDifferences(prevOwnerData.props, nextOwnerData.props),
stateDifferences: findObjectsDifferences(prevOwnerData.state, nextOwnerData.state),
hookDifferences: hookDifferences.length > 0 ? hookDifferences : false
};
}

function getUpdateReason(prevProps, prevState, prevHook, nextProps, nextState, nextHook, ownerDataMap) {
var prevOwnerData = ownerDataMap.get(prevProps);
var nextOwnerData = ownerDataMap.get(nextProps);
Expand All @@ -787,35 +814,25 @@ function getUpdateReason(prevProps, prevState, prevHook, nextProps, nextState, n
hookDifferences: findObjectsDifferences(prevHook, nextHook, {
shallow: false
}),
ownerDifferences: prevOwnerData != null && nextOwnerData != null ? {
propsDifferences: findObjectsDifferences(prevOwnerData.props, nextOwnerData.props),
stateDifferences: findObjectsDifferences(prevOwnerData.state, nextOwnerData.state),
hookDifferences: prevOwnerData.hooks.map(function (_ref, i) {
var hookName = _ref.hookName,
result = _ref.result;
return {
hookName: hookName,
differences: findObjectsDifferences(result, nextOwnerData.hooks[i].result, {
shallow: false
})
};
})
} : false
ownerDifferences: getOwnerDifferences({
prevOwnerData: prevOwnerData,
nextOwnerData: nextOwnerData
})
};
}

function getUpdateInfo(_ref2) {
var Component = _ref2.Component,
displayName = _ref2.displayName,
hookName = _ref2.hookName,
prevProps = _ref2.prevProps,
prevState = _ref2.prevState,
prevHook = _ref2.prevHook,
nextProps = _ref2.nextProps,
nextState = _ref2.nextState,
nextHook = _ref2.nextHook,
options = _ref2.options,
ownerDataMap = _ref2.ownerDataMap;
function getUpdateInfo(_ref3) {
var Component = _ref3.Component,
displayName = _ref3.displayName,
hookName = _ref3.hookName,
prevProps = _ref3.prevProps,
prevState = _ref3.prevState,
prevHook = _ref3.prevHook,
nextProps = _ref3.nextProps,
nextState = _ref3.nextState,
nextHook = _ref3.nextHook,
options = _ref3.options,
ownerDataMap = _ref3.ownerDataMap;
return {
Component: Component,
displayName: displayName,
Expand Down Expand Up @@ -900,7 +917,7 @@ function patchClassComponent(ClassComponent, displayName, React, options, ownerD
var _super = _createSuper(WDYRPatchedClassComponent);

function WDYRPatchedClassComponent(props, context) {
var _this;
var _thisSuper, _this;

_classCallCheck(this, WDYRPatchedClassComponent);

Expand All @@ -909,7 +926,7 @@ function patchClassComponent(ClassComponent, displayName, React, options, ownerD
renderNumber: 0
};

var origRender = _get(_getPrototypeOf(WDYRPatchedClassComponent.prototype), "render", _assertThisInitialized(_this)) || _this.render; // this probably means render is an arrow function or this.render.bind(this) was called on the original class
var origRender = _get((_thisSuper = _assertThisInitialized(_this), _getPrototypeOf(WDYRPatchedClassComponent.prototype)), "render", _thisSuper) || _this.render; // this probably means render is an arrow function or this.render.bind(this) was called on the original class


var renderIsABindedFunction = origRender !== ClassComponent.prototype.render;
Expand Down Expand Up @@ -1145,6 +1162,24 @@ function getPatchedComponent(componentsMap, Component, displayName, React, optio
return WDYRPatchedComponent;
}

function getIsSupportedComponentType(Comp) {
if (!Comp) {
return false;
}

if (typeof Comp === 'function') {
return true;
}

if (isMemoComponent(Comp)) {
return getIsSupportedComponentType(Comp.type);
}

if (isForwardRefComponent(Comp)) {
return getIsSupportedComponentType(Comp.render);
}
}

var hooksConfig = {
useState: {
path: '0'
Expand Down Expand Up @@ -1189,7 +1224,7 @@ function whyDidYouRender(React, userOptions) {
}

try {
isShouldTrack = (typeof componentNameOrComponent === 'function' || isMemoComponent(componentNameOrComponent) || isForwardRefComponent(componentNameOrComponent)) && shouldTrack({
isShouldTrack = getIsSupportedComponentType(componentNameOrComponent) && shouldTrack({
Component: componentNameOrComponent,
displayName: getDisplayName(componentNameOrComponent),
React: React,
Expand All @@ -1204,7 +1239,7 @@ function whyDidYouRender(React, userOptions) {
if (options.logOwnerReasons) {
var OwnerInstance = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner.current;

if (OwnerInstance != null) {
if (OwnerInstance) {
var Component = OwnerInstance.type.ComponentForHooksTracking || OwnerInstance.type;

var _displayName = getDisplayName(Component);
Expand Down
6 changes: 3 additions & 3 deletions dist/esm/whyDidYouRender.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/esm/whyDidYouRender.min.js.map

Large diffs are not rendered by default.

0 comments on commit ddaf0e8

Please sign in to comment.