Skip to content

Commit

Permalink
Update useEventListener.js
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Aug 13, 2024
1 parent 4720a3d commit a438fbe
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions frontend/common/useEventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ export const useEventListener = (
) => {
let handler_cached = useCallback(handler, deps)
useEffect(() => {
/** @type {EventListenerAddable} */
const useme = element != null && "current" in element ? element.current : element
const e = element
const useme =
e == null || e instanceof Document || e instanceof HTMLElement || e instanceof Window || e instanceof EventSource || e instanceof MediaQueryList
? e
: e.current

if (useme == null) return
useme.addEventListener(event_name, handler_cached)

Check failure on line 23 in frontend/common/useEventListener.js

View workflow job for this annotation

GitHub Actions / test

Property 'addEventListener' does not exist on type 'EventListenerAddable | Ref<EventListenerAddable>'.
Expand Down

0 comments on commit a438fbe

Please sign in to comment.