Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
ssr fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
EderOBarreto committed Jul 11, 2022
1 parent 7a10713 commit f3b162c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib/hooks/useBreakpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions src/lib/hooks/useWindowDimensions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect } from 'react'

export type WindowDimensions = {
export interface WindowDimensions {
width: {
px: number
rem: number
Expand All @@ -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

Expand Down

0 comments on commit f3b162c

Please sign in to comment.