MCPcopy
hub / github.com/gilbarbara/react-joyride / treeChanges

Function treeChanges

src/modules/changes.ts:3–20  ·  view source on GitHub ↗
(state: T, previous: T)

Source from the content-addressed store, hash-verified

1import type { StoreState } from '~/modules/store';
2
3export function treeChanges<T extends Record<string, any> = StoreState>(state: T, previous: T) {
4 return {
5 hasChanged<K extends keyof T>(key: K): boolean {
6 return state[key] !== previous[key];
7 },
8 hasChangedTo<K extends keyof T>(key: K, value: T[K] | T[K][]): boolean {
9 const current = state[key];
10 const previousValue = previous[key];
11
12 if (Array.isArray(value)) {
13 return value.includes(current) && !value.includes(previousValue);
14 }
15
16 return current === value && previousValue !== value;
17 },
18 previous,
19 };
20}

Callers 3

useScrollEffectFunction · 0.90
usePropSyncFunction · 0.90
useLifecycleEffectFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…