Skip to content

Commit

Permalink
fix: No window object
Browse files Browse the repository at this point in the history
  • Loading branch information
hampfh committed Feb 15, 2024
1 parent 92c7f56 commit 611080b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/shared/NavigationMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function NavigationMenu(props: React.HTMLAttributes<HTMLDivElement>) {

useEffect(() => {
// Always close sheet if its open when expanding the screen size
if (width > 768 && sheetOpen) {
if ((width ?? 0) > 768 && sheetOpen) {
setSheetOpen(false)
}
}, [width, sheetOpen])
Expand Down
10 changes: 7 additions & 3 deletions src/components/shared/hooks/useScreenSize.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
"use client"
import { useEffect, useState } from "react"

export function useScreenSize() {
const [screenSize, setScreenSize] = useState({
width: window.innerWidth,
height: window.innerHeight
const [screenSize, setScreenSize] = useState<{
width: number | undefined
height: number | undefined
}>({
width: undefined,
height: undefined
})

useEffect(() => {
Expand Down

0 comments on commit 611080b

Please sign in to comment.