Function useClientHeight

  • Custom React hook that retrieves the client height of an element.

    This hook listens for resize events on the specified element and updates the clientHeight state whenever the height of the element changes.

    Example

    const MyComponent = () => {
    const ref = useRef(null);
    const height = useClientHeight(ref);

    return (
    <div ref={ref}>
    <p>The height of this element is: {height}px</p>
    </div>
    );
    };

    Parameters

    • ref: THookEventElement<Element>

      A reference to the element whose client height is to be measured.

    Returns number