import { useEffect, useState } from 'react';
const useFetchQuery = (queryFn, { enabled = true } = {}) => {
    const [data, setData] = useState(null);
    const [isLoading, setIsLoading] = useState(false);
    const [error, setError] = useState(null);
    useEffect(() => {
        if (!enabled) {
            return;
        }
        const fetchData = async () => {
            setIsLoading(true);
            setError(null);
            setData(null);
            try {
                const result = await queryFn();
                setData(result);
            }
            catch (err) {
                setError(err);
            }
            finally {
                setIsLoading(false);
            }
        };
        void fetchData();
    }, [queryFn, enabled]);
    return { data, isLoading, error };
};
export default useFetchQuery;
//# sourceMappingURL=useFetchQuery.js.map