diff --git a/packages/common/src/hooks/useImageSize.ts b/packages/common/src/hooks/useImageSize.ts index fa939879f71..1dc3e5009dd 100644 --- a/packages/common/src/hooks/useImageSize.ts +++ b/packages/common/src/hooks/useImageSize.ts @@ -14,13 +14,14 @@ declare global { var IMAGE_CACHE: Set } -if (global) { +if (typeof global !== 'undefined') { if (!global.IMAGE_CACHE) { global.IMAGE_CACHE = new Set() } } -const IMAGE_CACHE = global.IMAGE_CACHE +const IMAGE_CACHE = + typeof global !== 'undefined' ? global.IMAGE_CACHE : new Set() // Gets the width from a given image size, e.g. '150x150' => 150 const getWidth = (size: string) => {