import type { RefObject } from 'react' ; import { useRef } from 'react' ; export type VisibilityReturnTuple < T > = [ boolean , RefObject < T > ] ; export function useVisibility < T extends HTMLElement > ( ) { const elementRef = useRef < T > ( null ) ; return [ ! ! elementRef . current ?. offsetParent , elementRef ] ; }