Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
30 lines
939 B
Plaintext
30 lines
939 B
Plaintext
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
var _tslib = require("tslib");
|
|
var _react = require("react");
|
|
function useWhyDidYouUpdate(componentName, props) {
|
|
var prevProps = (0, _react.useRef)({});
|
|
(0, _react.useEffect)(function () {
|
|
if (prevProps.current) {
|
|
var allKeys = Object.keys((0, _tslib.__assign)((0, _tslib.__assign)({}, prevProps.current), props));
|
|
var changedProps_1 = {};
|
|
allKeys.forEach(function (key) {
|
|
if (!Object.is(prevProps.current[key], props[key])) {
|
|
changedProps_1[key] = {
|
|
from: prevProps.current[key],
|
|
to: props[key]
|
|
};
|
|
}
|
|
});
|
|
if (Object.keys(changedProps_1).length) {
|
|
console.log('[why-did-you-update]', componentName, changedProps_1);
|
|
}
|
|
}
|
|
prevProps.current = props;
|
|
});
|
|
}
|
|
var _default = exports["default"] = useWhyDidYouUpdate; |