@lemon-fe/hooks 0.1.141 → 0.1.146
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/es/useRequest/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @param loadingState 启用loading状态
|
|
10
10
|
*/
|
|
11
11
|
export default function useRequest<T extends (...args: any[]) => PromiseLike<any>, K = T extends (...args: any) => PromiseLike<infer U> | infer U ? U : never>(request: T, options?: {
|
|
12
|
-
onLoading?: (loading
|
|
12
|
+
onLoading?: (loading: boolean) => void;
|
|
13
13
|
onSuccess?: (res: K) => void;
|
|
14
14
|
onError?: (err: Error) => void;
|
|
15
15
|
throttleInterval?: number;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
var useUpdateEffect = function useUpdateEffect(effect, deps) {
|
|
3
|
+
var isMounted = useRef(false);
|
|
4
|
+
// for react-refresh react 18
|
|
5
|
+
useEffect(function () {
|
|
6
|
+
return function () {
|
|
7
|
+
isMounted.current = false;
|
|
8
|
+
};
|
|
9
|
+
}, []);
|
|
10
|
+
useEffect(function () {
|
|
11
|
+
if (!isMounted.current) {
|
|
12
|
+
isMounted.current = true;
|
|
13
|
+
} else {
|
|
14
|
+
return effect();
|
|
15
|
+
}
|
|
16
|
+
}, deps);
|
|
17
|
+
};
|
|
18
|
+
export default useUpdateEffect;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lemon-fe/hooks",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.146",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "鲁盛杰 <lusj@cnlemon.net>",
|
|
6
6
|
"homepage": "",
|
|
@@ -25,5 +25,6 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/color-string": "^1.5.2",
|
|
27
27
|
"react": "^17.0.2"
|
|
28
|
-
}
|
|
28
|
+
},
|
|
29
|
+
"gitHead": "88632b58b09887447b008f24b5a59610aaf8e551"
|
|
29
30
|
}
|