Skip to content

Commit

Permalink
feat: add variables for SSR support (#78)
Browse files Browse the repository at this point in the history
Add variables for window and document with SSR support
  • Loading branch information
immois authored Dec 8, 2023
1 parent a4c1558 commit 52610e8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/hooks/use-event-listener/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { type RefObject, useEffect, useRef } from 'react';

export const _window = typeof window !== 'undefined' ? window : global.window;
export const _document =
typeof document !== 'undefined' ? document : global.document;

export const useEventListener = <T extends keyof HTMLElementEventMap>(
target: RefObject<EventTarget> | EventTarget,
eventType: T,
Expand Down

0 comments on commit 52610e8

Please sign in to comment.