react-native-tree-multi-select 3.0.0 → 3.0.1

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.
@@ -210,7 +210,7 @@ export function useScrollToNode<ID>(params: UseScrollToNodeParams<ID>) {
210
210
  viewPosition
211
211
  });
212
212
  } else {
213
- /* istanbul ignore next -- __DEV__ is false in test/production */
213
+ /* istanbul ignore else -- __DEV__ is always true in jest */
214
214
  if (__DEV__) {
215
215
  console.info("Cannot find the item of the mentioned id to scroll in the rendered tree view list data!");
216
216
  }
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  useEffect,
3
- useMemo,
4
3
  useRef,
5
4
  type DependencyList,
6
5
  type EffectCallback,
@@ -18,30 +17,21 @@ export default function useDeepCompareEffect(
18
17
  effect: EffectCallback,
19
18
  deps: DependencyList
20
19
  ) {
21
- // Ref to track if it's the first render
22
- const firstRenderRef = useRef<boolean>(true);
23
-
24
- // Memoized dependencies to avoid redundant `isEqual` checks
25
- const memoizedDependencies = useMemo(() => deps, [deps]);
26
-
27
20
  // Ref to store the previous dependencies
28
- const dependenciesRef = useRef<DependencyList>(memoizedDependencies);
21
+ const dependenciesRef = useRef<DependencyList>(deps);
29
22
 
30
- // Check for dependency changes
31
- const dependenciesChanged = !fastIsEqual(
32
- dependenciesRef.current,
33
- memoizedDependencies
34
- );
35
- if (dependenciesChanged) {
36
- dependenciesRef.current = memoizedDependencies;
37
- }
23
+ // Monotonic change counter: a boolean flag would stay `true` across two
24
+ // consecutive deep changes and useEffect would miss the second one.
25
+ const changeSignalRef = useRef(0);
38
26
 
39
- useEffect(() => {
40
- if (firstRenderRef.current) {
41
- firstRenderRef.current = false;
42
- }
27
+ if (!fastIsEqual(dependenciesRef.current, deps)) {
28
+ dependenciesRef.current = deps;
29
+ changeSignalRef.current += 1;
30
+ }
43
31
 
44
- return effect();
32
+ useEffect(
33
+ () => effect(),
45
34
  // eslint-disable-next-line react-hooks/exhaustive-deps
46
- }, [dependenciesChanged]); // exclude the effect function from the dependencies
35
+ [changeSignalRef.current] // exclude the effect function from the dependencies
36
+ );
47
37
  }