From a190eba0061366a1db227c8622a6582b774f9b89 Mon Sep 17 00:00:00 2001 From: Justin Date: Wed, 31 Aug 2022 14:32:13 -0400 Subject: [PATCH] Add polyfill for ResizeObserver --- app/soapbox/hooks/useDimensions.ts | 3 ++- package.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/soapbox/hooks/useDimensions.ts b/app/soapbox/hooks/useDimensions.ts index 2a265c4a6..bf7fc78b8 100644 --- a/app/soapbox/hooks/useDimensions.ts +++ b/app/soapbox/hooks/useDimensions.ts @@ -1,4 +1,5 @@ import { useEffect, useMemo, useState } from 'react'; +import ResizeObserver from 'resize-observer-polyfill'; type UseDimensionsRect = { width: number, height: number }; type UseDimensionsResult = [Element | null, any, any] @@ -14,7 +15,7 @@ const useDimensions = (): UseDimensionsResult => { const observer = useMemo( () => - new (window as any).ResizeObserver((entries: any) => { + new ResizeObserver((entries: any) => { if (entries[0]) { const { width, height } = entries[0].contentRect; setRect({ width, height }); diff --git a/package.json b/package.json index d5647cdec..eef743978 100644 --- a/package.json +++ b/package.json @@ -181,6 +181,7 @@ "redux-thunk": "^2.2.0", "requestidlecallback": "^0.3.0", "reselect": "^4.0.0", + "resize-observer-polyfill": "^1.5.1", "sass": "^1.20.3", "sass-loader": "^13.0.0", "semver": "^7.3.2",