@ptolemy2002/react-mount-effects 2.0.0 → 2.1.0
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/README.md +2 -2
- package/dist/main.d.ts +2 -2
- package/dist/main.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,10 +36,10 @@ None
|
|
|
36
36
|
|
|
37
37
|
### useDelayedEffect
|
|
38
38
|
#### Description
|
|
39
|
-
Runs the callback only after it has been triggered `delay + 1` times (since the first is on mount and does not represent a state change). The return value of the callback is
|
|
39
|
+
Runs the callback only after it has been triggered `delay + 1` times (since the first is on mount and does not represent a state change). The return value of the callback is used as the cleanup function for the effect.
|
|
40
40
|
|
|
41
41
|
#### Parameters
|
|
42
|
-
- `callback` (`
|
|
42
|
+
- `callback` (`changeCount: number, reset: () => void) => (() => void) | undefined`): The callback to run after the delay. The first parameter is the number of times the effect has been triggered since either initialization or last reset, and the second argument is a function that allows you to reset the counter.
|
|
43
43
|
- `deps` (`react.DependencyList`): An array of dependencies to listen to. This works exactly like the `useEffect` hook's dependencies. By default, this is an empty array.
|
|
44
44
|
- `delay` (`number`): The number of times the dependencies must change before the callback is run. Default is `0`, meaning the callback is run on any change, but not on mount.
|
|
45
45
|
|
package/dist/main.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DependencyList } from 'react';
|
|
1
|
+
import { DependencyList, EffectCallback } from 'react';
|
|
2
2
|
export declare function useMountEffect(callback: () => void): void;
|
|
3
3
|
export declare function useUnmountEffect(callback: () => void): void;
|
|
4
|
-
export declare function useDelayedEffect(callback: (changeCount: number, reset: () => void) =>
|
|
4
|
+
export declare function useDelayedEffect(callback: (changeCount: number, reset: () => void) => ReturnType<EffectCallback>, deps?: DependencyList, delay?: number): void;
|
package/dist/main.js
CHANGED
|
@@ -10,7 +10,7 @@ function s(e) {
|
|
|
10
10
|
function i(e, u = [], f = 0) {
|
|
11
11
|
const t = c(0);
|
|
12
12
|
n(() => {
|
|
13
|
-
t.current++, t.current > f + 1
|
|
13
|
+
if (t.current++, t.current > f + 1) return e(t.current, () => t.current = 0);
|
|
14
14
|
}, u);
|
|
15
15
|
}
|
|
16
16
|
export {
|