Skip to content

Commit

Permalink
fix: generic type on event arg in onClickAway callback on useClickAway
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipe Froes committed Jan 3, 2020
1 parent 57e1744 commit 4ffe454
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/useClickAway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { off, on } from './util';

const defaultEvents = ['mousedown', 'touchstart'];

const useClickAway = (
const useClickAway = <T extends Event>(
ref: RefObject<HTMLElement | null>,
onClickAway: (event: KeyboardEvent) => void,
onClickAway: (event: T | Event) => void,
events: string[] = defaultEvents
) => {
const savedCallback = useRef(onClickAway);
Expand Down
2 changes: 1 addition & 1 deletion stories/useClickAway.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ShowDocs from './util/ShowDocs';

const Demo = () => {
const ref = useRef(null);
useClickAway(ref, action('outside clicked'));
useClickAway<MouseEvent>(ref, action('outside clicked'));

return (
<div
Expand Down

0 comments on commit 4ffe454

Please sign in to comment.