Files
blitzkit/src/hooks/useWideFormat.ts
T

19 lines
442 B
TypeScript
Raw Normal View History

2024-02-17 10:23:43 -06:00
import { useEffect, useState } from 'react';
2024-04-18 18:42:57 -05:00
export function useWideFormat(size = 880) {
function hasWideFormat() {
return typeof window !== 'undefined' && window.innerWidth > size;
}
2024-02-17 10:23:43 -06:00
const [wideFormat, setWideFormat] = useState(hasWideFormat());
useEffect(() => {
function handleResize() {
setWideFormat(hasWideFormat());
}
window.addEventListener('resize', handleResize);
}, []);
2024-02-16 21:07:48 -06:00
return wideFormat;
}