UNPKG

@mapbox-react/env-layers

Version:

Mapbox React Component Library Env Layers

20 lines (19 loc) 662 B
import { jsx as a } from "react/jsx-runtime"; import { useContext as s, useRef as n } from "react"; import { useMount as c, useUnmount as u } from "ahooks"; import { v4 as p } from "uuid"; import { MapContext as i } from "@mapbox-react/core"; import f from "@mapbox-web/deck-gl-extension"; function w(m) { const o = s(i), t = n(null), e = n(m.id || p()); return c(() => { const r = o.mapboxInstance; t.current = new f.SnowLayer(e.current), r.addLayer(t.current); }), u(() => { const r = o.mapboxInstance; r && t.current && r.removeLayer(e.current); }), /* @__PURE__ */ a("i", { className: "mb-snow-layer" }); } export { w as default };