"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = require("react");
var azure_maps_control_1 = require("azure-maps-control");
var AzureMapDataSourceContext_1 = require("../../contexts/AzureMapDataSourceContext");
var useCheckRef_1 = require("../../hooks/useCheckRef");
var useCreateAzureMapFeature_1 = require("./useCreateAzureMapFeature");
var AzureMapFeature = react_1.memo(function (props) {
    var properties = props.properties, id = props.id;
    var dataSourceRef = react_1.useContext(AzureMapDataSourceContext_1.AzureMapDataSourceContext).dataSourceRef;
    var _a = react_1.useState(null), featureRef = _a[0], setFeatureRef = _a[1];
    react_1.useEffect(function () {
        var featureSource = useCreateAzureMapFeature_1.useCreateAzureMapFeatureFeature(props);
        if (!featureRef && featureSource) {
            setFeatureRef(new azure_maps_control_1.default.data.Feature(featureSource, properties, id));
        }
    }, []);
    useCheckRef_1.useCheckRef(dataSourceRef, featureRef, function (dref, fref) {
        dref.add(fref);
        return function () {
            dref.remove(fref);
        };
    });
    return null;
});
exports.default = AzureMapFeature;
//# sourceMappingURL=AzureMapFeature.js.map