import { useCallback, useEffect, useRef } from 'react';
export function useRAF(fn) {
    const rafRef = useRef(null);
    useEffect(() => {
        return () => {
            if (rafRef.current !== null) {
                cancelAnimationFrame(rafRef.current);
                rafRef.current = null;
            }
        };
    }, [fn]);
    return useCallback(() => {
        if (rafRef.current === null) {
            rafRef.current = requestAnimationFrame(() => {
                rafRef.current = null;
                fn();
            });
        }
    }, [fn]);
}
//# sourceMappingURL=useRAF.js.map
