From b708153b3347ecf1c08c71f841be6e432669c7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Poduszl=C3=B3?= Date: Sat, 26 Oct 2019 00:41:58 +0200 Subject: [PATCH] fix(useSize): possible ReferenceError caused by accessing ResizeObserver --- packages/web-api-hooks/src/useSize.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/web-api-hooks/src/useSize.ts b/packages/web-api-hooks/src/useSize.ts index aa82e91..ed7c87b 100644 --- a/packages/web-api-hooks/src/useSize.ts +++ b/packages/web-api-hooks/src/useSize.ts @@ -25,10 +25,10 @@ export default function useSize( const [size, setSize] = useState>([0, 0]); useEffect(() => { - const CustomResizeObserver = ResizeObserverOverride || ResizeObserver; - if (!CustomResizeObserver || !ref.current) return undefined; + const ResizeObserver = ResizeObserverOverride || window.ResizeObserver; + if (!ResizeObserver || !ref.current) return undefined; - const observer = new CustomResizeObserver(([entry]) => { + const observer = new ResizeObserver(([entry]) => { const { width, height } = entry.contentRect; setSize([width, height]); });