diff --git a/src/utility/useIsDesktop.ts b/src/utility/useIsDesktop.ts index 729c6639..2e58ba89 100644 --- a/src/utility/useIsDesktop.ts +++ b/src/utility/useIsDesktop.ts @@ -4,18 +4,16 @@ export default function useIsDesktop() { const [isDesktop, setIsDesktop] = useState(); useEffect(() => { - if (typeof window !== 'undefined') { - const breakpointMd = getComputedStyle(document.body) - .getPropertyValue('--breakpoint-md'); - const mql = window.matchMedia(`(min-width: ${breakpointMd})`); - setIsDesktop(mql.matches); + const breakpointMd = getComputedStyle(document.body) + .getPropertyValue('--breakpoint-md'); + const mql = window.matchMedia(`(min-width: ${breakpointMd})`); + setIsDesktop(mql.matches); - const eventHandler = (event: MediaQueryListEvent) => - setIsDesktop(event.matches); + const eventHandler = (event: MediaQueryListEvent) => + setIsDesktop(event.matches); - mql.addEventListener('change', eventHandler); - return () => mql.removeEventListener('change', eventHandler); - } + mql.addEventListener('change', eventHandler); + return () => mql.removeEventListener('change', eventHandler); }, []); return isDesktop;