We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 920d216 commit f07e0d6Copy full SHA for f07e0d6
src/hooks/useEvent.ts
@@ -1,14 +1,12 @@
1
-/* eslint-disable @typescript-eslint/ban-types */
2
-/* eslint-disable react-hooks/exhaustive-deps */
3
import * as React from 'react';
4
5
-function useEvent<T extends ((...args: any[]) => any) | undefined>(
+const useEvent = <T extends ((...args: any[]) => any) | undefined>(
6
callback: T,
7
): undefined extends T
8
? (
9
...args: Parameters<NonNullable<T>>
10
) => ReturnType<NonNullable<T>> | undefined
11
- : T {
+ : T => {
12
const fnRef = React.useRef<T | undefined>(callback);
13
fnRef.current = callback;
14
@@ -18,6 +16,6 @@ function useEvent<T extends ((...args: any[]) => any) | undefined>(
18
16
);
19
17
20
return memoFn;
21
-}
+};
22
23
export default useEvent;
0 commit comments