@mittwald/react-ghostmaker 1.4.3 → 1.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/useGhostChain.js +9 -10
- package/package.json +1 -1
|
@@ -59,22 +59,21 @@ const useGhostChainItem = (target, item, options = {}, context) => {
|
|
|
59
59
|
const targetHashes = new Map();
|
|
60
60
|
const useTargetAutoInvalidate = (target, queryKey) => {
|
|
61
61
|
const queryClient = useQueryClient();
|
|
62
|
-
const invalidate = () => queryClient.invalidateQueries({
|
|
63
|
-
queryKey,
|
|
64
|
-
});
|
|
65
|
-
const targetHash = hashObject(target);
|
|
66
|
-
const joinedQueryKey = queryKey.join(".");
|
|
67
|
-
const prevTargetHash = targetHashes.get(joinedQueryKey);
|
|
68
|
-
const needsRefresh = prevTargetHash !== undefined && prevTargetHash !== targetHash;
|
|
69
|
-
targetHashes.set(joinedQueryKey, targetHash);
|
|
70
62
|
const onTargetChangeEvent = useEffectEvent(() => {
|
|
63
|
+
const joinedQueryKey = queryKey.join(".");
|
|
64
|
+
const targetHash = hashObject(target);
|
|
65
|
+
const prevTargetHash = targetHashes.get(joinedQueryKey);
|
|
66
|
+
const needsRefresh = prevTargetHash !== undefined && prevTargetHash !== targetHash;
|
|
67
|
+
targetHashes.set(joinedQueryKey, targetHash);
|
|
71
68
|
if (needsRefresh) {
|
|
72
|
-
|
|
69
|
+
queryClient.invalidateQueries({
|
|
70
|
+
queryKey,
|
|
71
|
+
});
|
|
73
72
|
}
|
|
74
73
|
});
|
|
75
74
|
useEffect(() => {
|
|
76
75
|
onTargetChangeEvent();
|
|
77
|
-
}, [
|
|
76
|
+
}, [target]);
|
|
78
77
|
};
|
|
79
78
|
/** @internal */
|
|
80
79
|
export const cleanupTargetHashes = () => {
|