import { useContext, useEffect, useState } from 'react';
import { PageRequestsAbortingContext } from '../contexts/PageRequestsAbortingContext';
export var useGeography = function (geoUrl) {
    var _a = useState(null), geography = _a[0], setGeography = _a[1];
    var signal = useContext(PageRequestsAbortingContext);
    useEffect(function () {
        fetch(geoUrl, { signal: signal })
            .then(function (res) {
            if (!res.ok) {
                throw Error(res.statusText);
            }
            return res.json();
        })
            .then(function (geography) {
            setGeography(geography);
        })
            .catch(function (error) {
            console.warn("Could not load map ".concat(geoUrl, " :"), error);
        });
    }, []); // eslint-disable-line
    return geography;
};
