diff --git a/src/lib/hooks/useBreakpoints.ts b/src/lib/hooks/useBreakpoints.ts index 24ecb99..bc90bd7 100644 --- a/src/lib/hooks/useBreakpoints.ts +++ b/src/lib/hooks/useBreakpoints.ts @@ -16,7 +16,7 @@ const parseBreakpoints = (breakpoints: Screens): NumberedBreakpoints => { return parsed as NumberedBreakpoints } -export type BreakpointsProps = { +export interface BreakpointsProps { breakpoints: NumberedBreakpoints current: keyof Screens isMobile: boolean diff --git a/src/lib/hooks/useWindowDimensions.ts b/src/lib/hooks/useWindowDimensions.ts index 8b55880..a029099 100644 --- a/src/lib/hooks/useWindowDimensions.ts +++ b/src/lib/hooks/useWindowDimensions.ts @@ -1,6 +1,6 @@ import { useState, useEffect } from 'react' -export type WindowDimensions = { +export interface WindowDimensions { width: { px: number rem: number @@ -11,9 +11,14 @@ export type WindowDimensions = { } } -function getWindowDimensions(): WindowDimensions { - const width = window?.innerWidth || 0 - const height = window?.innerHeight || 0 +const getWindowDimensions = (): WindowDimensions => { + let width = 0 + let height = 0 + + if (typeof window !== 'undefined') { + width = window?.innerWidth + height = window?.innerHeight + } const rootFontSize = parseInt(getComputedStyle(document?.documentElement)?.fontSize) ?? 16