@vinctus/react-maplibre 0.2.24 → 0.2.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/Map.js +10 -2
  2. package/package.json +1 -1
package/dist/Map.js CHANGED
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import React, { useRef, useEffect, useState, useContext, useImperativeHandle, useMemo, } from 'react';
13
+ import React, { useRef, useEffect, useState, useContext, useImperativeHandle, useMemo, useCallback, } from 'react';
14
14
  import maplibre from 'maplibre-gl';
15
15
  import { ErrorBoundary } from './ErrorBoundary'; // eslint-disable-line import/no-webpack-loader-syntax
16
16
  const DEFAULT_STYLE = 'https://demotiles.maplibre.org/style.json';
@@ -34,7 +34,13 @@ export const useMap = () => useContext(MapContext);
34
34
  export const MapProvider = ({ children }) => {
35
35
  const [map, setMap] = useState(null);
36
36
  const [mapLoaded, setMapLoaded] = useState(false);
37
- return (_jsx(MapContext.Provider, { value: { map, setMap, mapLoaded, setMapLoaded }, children: children }));
37
+ const stableSetMap = useCallback((newMap) => {
38
+ setMap(newMap);
39
+ }, []);
40
+ const stableSetMapLoaded = useCallback((loaded) => {
41
+ setMapLoaded(loaded);
42
+ }, []);
43
+ return (_jsx(MapContext.Provider, { value: { map, setMap: stableSetMap, mapLoaded, setMapLoaded: stableSetMapLoaded }, children: children }));
38
44
  };
39
45
  function addEventHandler(map, type, handler) {
40
46
  map.on(type, (ev) => handler(Object.assign({ viewState: viewStateFromMap(map) }, ev)));
@@ -87,6 +93,8 @@ export const Map = React.forwardRef((_a, ref) => {
87
93
  onLoad,
88
94
  onMoveEnd,
89
95
  onZoomEnd,
96
+ setMap,
97
+ setMapLoaded,
90
98
  ]);
91
99
  const memoizedStyle = useMemo(() => (Object.assign({ position: 'relative', width: '100%', height: '100%' }, style)), [style]);
92
100
  return (_jsx(ErrorBoundary, { fallback: fallback, children: _jsx("div", { id: id, ref: mapContainer, style: memoizedStyle, children: children }) }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vinctus/react-maplibre",
3
- "version": "0.2.24",
3
+ "version": "0.2.25",
4
4
  "description": "Minimalist MapLibre GL JS React wrapper library",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts",