@rc-component/util 1.3.0 → 1.3.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.
package/es/hooks/useEvent.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function useEvent<T extends
|
|
1
|
+
declare function useEvent<T extends ((...args: any[]) => any) | undefined>(callback: T): undefined extends T ? (...args: Parameters<NonNullable<T>>) => ReturnType<NonNullable<T>> | undefined : T;
|
|
2
2
|
export default useEvent;
|
package/es/hooks/useEvent.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
function useEvent(callback) {
|
|
5
|
-
const fnRef = React.useRef();
|
|
5
|
+
const fnRef = React.useRef(callback);
|
|
6
6
|
fnRef.current = callback;
|
|
7
7
|
const memoFn = React.useCallback((...args) => fnRef.current?.(...args), []);
|
|
8
8
|
return memoFn;
|
package/lib/hooks/useEvent.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function useEvent<T extends
|
|
1
|
+
declare function useEvent<T extends ((...args: any[]) => any) | undefined>(callback: T): undefined extends T ? (...args: Parameters<NonNullable<T>>) => ReturnType<NonNullable<T>> | undefined : T;
|
|
2
2
|
export default useEvent;
|
package/lib/hooks/useEvent.js
CHANGED
|
@@ -11,7 +11,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
11
11
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
12
12
|
|
|
13
13
|
function useEvent(callback) {
|
|
14
|
-
const fnRef = React.useRef();
|
|
14
|
+
const fnRef = React.useRef(callback);
|
|
15
15
|
fnRef.current = callback;
|
|
16
16
|
const memoFn = React.useCallback((...args) => fnRef.current?.(...args), []);
|
|
17
17
|
return memoFn;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rc-component/util",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Common Utils For React Component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"@rc-component/father-plugin": "^2.0.1",
|
|
46
46
|
"@rc-component/np": "^1.0.3",
|
|
47
47
|
"@testing-library/react": "^16.0.0",
|
|
48
|
-
"@types/jest": "^
|
|
49
|
-
"@types/node": "^
|
|
48
|
+
"@types/jest": "^30.0.0",
|
|
49
|
+
"@types/node": "^24.6.1",
|
|
50
50
|
"@types/react": "^18.0.0",
|
|
51
51
|
"@types/react-dom": "^18.0.0",
|
|
52
52
|
"@types/react-is": "^19.0.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"eslint-plugin-jest": "^28.2.0",
|
|
60
60
|
"eslint-plugin-unicorn": "^56.0.1",
|
|
61
61
|
"father": "^4.1.3",
|
|
62
|
-
"glob": "^
|
|
62
|
+
"glob": "^11.0.3",
|
|
63
63
|
"husky": "^9.1.6",
|
|
64
64
|
"lint-staged": "^15.1.0",
|
|
65
65
|
"prettier": "^3.3.2",
|