/** * Calls a provided callback when the provided element moves into or out of the viewport. * * Example: * * ```js * import { useRef, useCallback } from 'react' * import { useIntersectionObserver } from '@edgio/react' * * function MyComponent() { * const ref = useRef(null) * * const onVisibilityChange = useCallback((visible, disconnect) => { * if (visible) { * // do some side effect here * // and optionally stop observing by calling: disconnect() * } * }, []) * * useIntersectionObserver(() => ref, onVisibilityChange, []) * return
* } * ``` * * @param {Function} getRef A function that returns a ref pointing to the element to observe * @param {Function} cb A callback to call when visibility changes * @param {Object[]} deps The IntersectionObserver will be updated to observe a new ref whenever any of these change */ export default function useIntersectionObserver(getRef: Function, cb: Function, deps: Array>): void;