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",