import { RefObject , useLayoutEffect , useState } from 'react' ; export const useMaxHeight = ( bodyRef ) => { const [ maxHeight , setMaxHeight ] = useState ( 0 ) ; useLayoutEffect ( ( ) => { if ( ! bodyRef . current ) { return ; } const { height } = bodyRef . current . getBoundingClientRect ( ) ; if ( height !== 0 && ( height + 100 ) > maxHeight ) { setMaxHeight ( height + 100 ) ; } } ) ; return maxHeight ; } ;