import { useEffect } from "react" import { ComponentType, forwardRef } from "react" interface Props { style?: React.CSSProperties [key: string]: any } export function withMobileSafeDVH(Component): ComponentType { return forwardRef((props, ref) => { useEffect(() => { const setVh = () => { const vh = window.innerHeight * 0.01 document.documentElement.style.setProperty("--vh", `${vh}px`) } setVh() window.addEventListener("resize", setVh) return () => window.removeEventListener("resize", setVh) }, []) return ( ) }) }
import { useEffect } from "react" import { ComponentType, forwardRef } from "react" interface Props { style?: React.CSSProperties [key: string]: any } export function withMobileSafeDVH(Component): ComponentType { return forwardRef((props, ref) => { useEffect(() => { const setVh = () => { const vh = window.innerHeight * 0.01 document.documentElement.style.setProperty("--vh", `${vh}px`) } setVh() window.addEventListener("resize", setVh) return () => window.removeEventListener("resize", setVh) }, []) return ( ) }) }