maintainermonth/hooks/useViewportHeight.js

17 строки
424 B
JavaScript

import { useEffect } from 'react'
const useViewportHeight = () => {
useEffect(() => {
const handleResize = () => {
const vh = window.innerHeight * 0.01
document.documentElement.style.setProperty('--vh', `${vh}px`)
}
handleResize()
window.addEventListener('resize', handleResize)
return () => window.removeEventListener('resize', handleResize)
}, [])
}
export default useViewportHeight