Skip to content

Commit bab00b3

Browse files
committed
futher improve typing to allow generics
1 parent 9e373fa commit bab00b3

File tree

5 files changed

+8
-14
lines changed

5 files changed

+8
-14
lines changed

dist/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ interface optionType {
55
interval?: number;
66
timeout?: number;
77
}
8-
export declare function useHoverIntent(options: optionType): [boolean, React.RefObject<HTMLElement>];
8+
export declare function useHoverIntent<T = HTMLElement>(options: optionType): [boolean, React.RefObject<HTMLElement & T>];
99
export {};

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-use-hoverintent",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"description": "React hook for hoverIntent",
55
"main": "dist/index.js",
66
"module": "dist/index.js",
@@ -27,13 +27,10 @@
2727
"typescript": "^4.1.2"
2828
},
2929
"repository": "https://github.com/llldar/react-use-hoverintent",
30-
"peerDependencies": {
31-
"react": "^16.8.0"
32-
},
3330
"exclude": [
3431
"node_modules"
3532
],
3633
"scripts": {
3734
"build": "rimraf dist && tsc --emitDeclarationOnly && babel src --out-dir dist --extensions .ts,.tsx && copyfiles package.json LICENSE.md README.md ./dist"
3835
}
39-
}
36+
}

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,10 @@
2727
"typescript": "^4.1.2"
2828
},
2929
"repository": "https://github.com/llldar/react-use-hoverintent",
30-
"peerDependencies": {
31-
"react": "^16.8.0"
32-
},
3330
"exclude": [
3431
"node_modules"
3532
],
3633
"scripts": {
3734
"build": "rimraf dist && tsc --emitDeclarationOnly && babel src --out-dir dist --extensions .ts,.tsx && copyfiles package.json LICENSE.md README.md ./dist"
3835
}
39-
}
36+
}

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ interface optionType {
77
timeout?: number;
88
}
99

10-
export function useHoverIntent(
10+
export function useHoverIntent<T = HTMLElement>(
1111
options: optionType
12-
): [boolean, React.RefObject<HTMLElement>] {
12+
): [boolean, React.RefObject<HTMLElement & T>] {
1313
const { ref, sensitivity = 6, interval = 100, timeout = 0 } = options;
14-
const intentRef = useRef<HTMLElement>(null);
14+
const intentRef = useRef<HTMLElement & T>(null);
1515
const [isHovering, setIsHovering] = useState(false);
1616

1717
let x = 0,

0 commit comments

Comments
 (0)