const [dimensions, setDimensions] = useState({
height: typeof window !== 'undefined' && window.innerHeight,
width: typeof window !== 'undefined' && window.innerWidth,
});
useEffect(() => {
const handleResize = () => {
setDimensions({
height: window.innerHeight,
width: window.innerWidth,
});
};
window.addEventListener('resize', handleResize);
}, []);
return {
{console.log(`Rendered at ${dimensions.width} x ${dimensions.height}`)}
}