import { useRef, useCallback, useEffect } from 'react';
export function useAnimationFramed(callback) {
    var callbackRef = useRef(callback);
    var handleRef = useRef(null);
    useEffect(function () {
        callbackRef.current = callback;
    }, [callback]);
    return useCallback(function () {
        if (!handleRef.current) {
            handleRef.current = requestAnimationFrame(function () {
                handleRef.current = null;
                callbackRef.current();
            });
        }
    }, []);
}
