import React , { useEffect , useRef } from 'react' ; export function HeightRetainer ( props ) { const containerElement = useRef < HTMLDivElement > ( null ) ; const minHeight = useRef < number > ( 0 ) ; useEffect ( ( ) => { if ( containerElement . current ) { const currentHeight = containerElement . current . clientHeight ; if ( minHeight . current < currentHeight ) { minHeight . current = currentHeight ; } } } ) ; return ( < div { ... props } ref = { containerElement } style = { { minHeight : minHeight . current } } />); }