This commit is contained in:
Muhammad Eko 2024-10-01 15:31:58 +07:00
parent 85b91793b5
commit c212a837cd
1 changed files with 4 additions and 1 deletions

View File

@ -1,4 +1,3 @@
"use client"
import { RefObject, useMemo, useSyncExternalStore } from "react"
function subscribe(callback: (e: Event) => void) {
@ -15,6 +14,10 @@ function useDimensions(ref: RefObject<HTMLElement>) {
width: ref.current?.offsetWidth ?? 0,
height: ref.current?.offsetHeight ?? 0,
}),
() => JSON.stringify({
width: window.innerWidth,
height: window.innerHeight
})
)
return useMemo(() => JSON.parse(dimensions), [dimensions])
}