urbi-exhibitions
Version:
31 lines (30 loc) • 785 B
JavaScript
import { jsx as i } from "react/jsx-runtime";
import { createContext as u, useContext as d, useState as m, useCallback as M } from "react";
const o = u(void 0);
function l() {
const t = d(o);
if (t === void 0)
throw new Error("useMap must be used within an MapProvider");
return t;
}
const v = ({ children: t }) => {
const [s, a] = m(
void 0
), n = M(
(p) => a((e) => {
var r;
if (e != null && e.map)
return {
...e,
map: { ...e.map, state: { ...(r = e == null ? void 0 : e.map) == null ? void 0 : r.state, ...p } }
};
}),
[a]
);
return /* @__PURE__ */ i(o.Provider, { value: { ...s, setMapContext: a, updateMapState: n }, children: t });
};
v.displayName = "MapProvider";
export {
v as M,
l as u
};