import type { ReactElement } from 'react'; import Measure from 'react-measure'; import styles from './Toolbar.module.css'; interface Props { children: ReactElement; knownWidth: number | undefined; onMeasure: (width: number) => void; } function MeasuredControl(props: Props) { const { children: child, knownWidth, onMeasure } = props; return ( { if (entry && entry.width > (knownWidth || 0)) { onMeasure(entry.width); } }} > {({ measureRef }) => (
{child}
)}
); } export default MeasuredControl;