import { RefObject , useLayoutEffect , useState } from 'react' ; const DEFAULT = { y : 0 , x : 0 , width : 100 , height : 100 , } ; const useSvgGraphicsBbox = ( ref , deps = [ ] ) => { const [ bbox , setBbox ] = useState ( DEFAULT ) ; useLayoutEffect ( ( ) => { if ( ! ref . current ) { setBbox ( DEFAULT ) ; return ; } setBbox ( ref . current . getBBox ( ) ) ; } , [ ref . current , ... deps ] ) ; return bbox ; } ; export default useSvgGraphicsBbox ;