From 52610e8b848708920692ba90ea270d89d3acbfe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mois=C3=A9s=20Machuca=20Valverde?= Date: Thu, 7 Dec 2023 23:48:17 -0500 Subject: [PATCH] feat: add variables for SSR support (#78) Add variables for window and document with SSR support --- packages/hooks/use-event-listener/src/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/hooks/use-event-listener/src/index.ts b/packages/hooks/use-event-listener/src/index.ts index b559c90..037d55f 100644 --- a/packages/hooks/use-event-listener/src/index.ts +++ b/packages/hooks/use-event-listener/src/index.ts @@ -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 = ( target: RefObject | EventTarget, eventType: T,