Files
NapCatQQ/.pnpm-store/v3/files/d0/5dd60d88eb614668d5f7b1dac25efeed8bd2dd342c881acf12d34057de121052804fc38eb078d32d62c84817b227e7529d654bb00683802267541fe95ac518
TanTan e311ca3275
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
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

25 lines
900 B
Plaintext

import { __assign } from "tslib";
import { useEffect, useRef } from 'react';
function useWhyDidYouUpdate(componentName, props) {
var prevProps = useRef({});
useEffect(function () {
if (prevProps.current) {
var allKeys = Object.keys(__assign(__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;
});
}
export default useWhyDidYouUpdate;