UNPKG

@kgdata/forcegraph

Version:
17 lines (12 loc) 437 B
import { useState, useEffect } from 'react'; import type { Target } from '../../utils'; import { getAutoHeight, getTargetElement } from '../../utils'; const useAutoHeight = (target: Target) => { const [height, setHeight] = useState<number>(0); useEffect(() => { const el = getTargetElement(target); if (el) setHeight(getAutoHeight(el)); }, [target]); return [height]; }; export default useAutoHeight;