import * as React from 'react';
import { getResizeObserverObject } from '../ResizeObserver/getResizeObserverObject';
const RO = getResizeObserverObject();
const NotifyResize = (props) => {
    const domRef = React.useRef(null);
    React.useEffect(() => {
        if (!RO) {
            return;
        }
        const ro = new RO((entries) => {
            const entry = entries[0];
            if (entry) {
                const { width, height } = entry.contentRect;
                props.onResize({ width, height });
            }
        });
        const domNode = domRef.current;
        ro.observe(domNode);
        return () => {
            if (domNode) {
                ro.unobserve(domNode);
            }
        };
    }, []);
    return (React.createElement("div", { ref: domRef, style: {
            visibility: 'hidden',
            position: 'absolute',
            width: '100%',
            height: '100%',
            top: 0,
            left: 0,
        } }));
};
export default NotifyResize;
