@dxos/react-hooks 0.6.11 → 0.6.12-main.568932b

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.
@@ -28,21 +28,18 @@ export const useDidTransition = <T>(
28
28
 
29
29
  useEffect(() => {
30
30
  const toValueValid = isFunction<T>(toValue) ? toValue(currentValue) : toValue === currentValue;
31
-
32
31
  const fromValueValid = isFunction<T>(fromValue)
33
32
  ? fromValue(previousValue.current)
34
33
  : fromValue === previousValue.current;
35
34
 
36
- const transitioned = fromValueValid && toValueValid;
37
-
38
- if (transitioned) {
35
+ if (fromValueValid && toValueValid && !hasTransitioned) {
39
36
  setHasTransitioned(true);
40
- } else {
37
+ } else if ((!fromValueValid || !toValueValid) && hasTransitioned) {
41
38
  setHasTransitioned(false);
42
39
  }
43
40
 
44
41
  previousValue.current = currentValue;
45
- }, [currentValue, fromValue, toValue, setHasTransitioned, previousValue]);
42
+ }, [currentValue, fromValue, toValue, hasTransitioned]);
46
43
 
47
44
  return hasTransitioned;
48
45
  };
@@ -55,7 +52,7 @@ export const useDidTransition = <T>(
55
52
  export const useOnTransition = <T>(
56
53
  currentValue: T,
57
54
  fromValue: T | ((value: T) => boolean),
58
- toValue: ((value: T) => boolean) | T,
55
+ toValue: T | ((value: T) => boolean),
59
56
  callback: () => void,
60
57
  ) => {
61
58
  const dirty = useRef(false);
@@ -1,5 +0,0 @@
1
- /**
2
- * NOTE: Use with care and when necessary to be able to cancel an async operation when unmounting.
3
- */
4
- export declare const useAsyncCallback: <T>(cb: () => Promise<T>) => T | undefined;
5
- //# sourceMappingURL=useAsyncCallback.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAsyncCallback.d.ts","sourceRoot":"","sources":["../../../src/useAsyncCallback.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,MAAM,MAAM,OAAO,CAAC,CAAC,CAAC,KAAG,CAAC,GAAG,SAY9D,CAAC"}