/** * 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