Files
blitzkit/src/hooks/useWideFormat.ts
T
2024-02-17 10:23:43 -06:00

20 lines
425 B
TypeScript

import { useEffect, useState } from 'react';
function hasWideFormat() {
return typeof window !== 'undefined' && window.innerWidth > 880;
}
export function useWideFormat() {
const [wideFormat, setWideFormat] = useState(hasWideFormat());
useEffect(() => {
function handleResize() {
setWideFormat(hasWideFormat());
}
window.addEventListener('resize', handleResize);
}, []);
return wideFormat;
}