UNPKG

@itwin/itwinui-react

Version:

A react component library for iTwinUI

17 lines (16 loc) 744 B
/** * Hook that returns the width of an element in three stages: * - initialized with 0 * - immediately set to element's initial width as soon as it's mounted * - update to new width every time it changes (using `useResizeObserver` hook) * * @private * @param watchResizes If false, ResizeObserver will not be connected and only the initial width will be returned * @returns [ref to attach to the element, stateful width of the element] * * @example * const [ref, width] = useContainerWidth(); * ... // do something with width * return <div ref={ref}>...</div>; */ export declare const useContainerWidth: <T extends HTMLElement>(watchResizes?: boolean) => readonly [(instance: HTMLElement | null | undefined) => void, number];