import { useState, useLayoutEffect } from 'react';
import { subscribe } from './resizeObserverService.js';

/**
 * useResizeSignal
 * The hook "pokes" the component whenever a resize happens.
 */
const useResizeSignal = (ref) => {
    const [signal, setSignal] = useState(0);
    useLayoutEffect(() => {
        const el = ref.current;
        if (!el)
            return;
        const unsubscribe = subscribe(el, () => setSignal((s) => s + 1));
        return unsubscribe;
    }, [ref]);
    return signal;
};

export { useResizeSignal };
//# sourceMappingURL=useResizeSignal.js.map
