From ad094311454c48873ba7143654a29b8a0c54459d Mon Sep 17 00:00:00 2001 From: streamich Date: Sun, 10 Nov 2019 20:03:41 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20check=20window.Event=20co?= =?UTF-8?q?nstructor=20exists=20in=20useLocation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit IE does not have window.Event constructor. --- src/useLocation.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/useLocation.ts b/src/useLocation.ts index 4ab872df..0ac48135 100644 --- a/src/useLocation.ts +++ b/src/useLocation.ts @@ -84,4 +84,6 @@ const useLocationBrowser = (): LocationSensorState => { return state; }; -export default isClient ? useLocationBrowser : useLocationServer; +const hasEventConstructor = typeof Event === 'function'; + +export default isClient && hasEventConstructor ? useLocationBrowser : useLocationServer;