@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.
- package/dist/lib/browser/index.mjs +25 -24
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +23 -22
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +327 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/useAsyncEffect.test.d.ts +1 -1
- package/dist/types/src/useAsyncEffect.test.d.ts.map +1 -1
- package/dist/types/src/useAsyncState.d.ts +6 -0
- package/dist/types/src/useAsyncState.d.ts.map +1 -0
- package/dist/types/src/useDefaultValue.d.ts +1 -1
- package/dist/types/src/useDefaultValue.d.ts.map +1 -1
- package/dist/types/src/useMulticastObservable.test.d.ts +2 -0
- package/dist/types/src/useMulticastObservable.test.d.ts.map +1 -0
- package/dist/types/src/useTransitions.d.ts +1 -1
- package/dist/types/src/useTransitions.d.ts.map +1 -1
- package/package.json +8 -6
- package/src/index.ts +1 -1
- package/src/useAsyncEffect.test.tsx +3 -9
- package/src/{useAsyncCallback.ts → useAsyncState.ts} +7 -4
- package/src/useDefaultValue.ts +2 -2
- package/src/useMulticastObservable.test.tsx +23 -0
- package/src/useTransitions.ts +4 -7
- package/dist/types/src/useAsyncCallback.d.ts +0 -5
- package/dist/types/src/useAsyncCallback.d.ts.map +0 -1
package/src/useTransitions.ts
CHANGED
|
@@ -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
|
-
|
|
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,
|
|
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)
|
|
55
|
+
toValue: T | ((value: T) => boolean),
|
|
59
56
|
callback: () => void,
|
|
60
57
|
) => {
|
|
61
58
|
const dirty = useRef(false);
|
|
@@ -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"}
|