@page-speed/maps 0.2.2 → 0.2.3

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.
package/dist/index.cjs CHANGED
@@ -1201,18 +1201,38 @@ function GeoMap({
1201
1201
  const viewStateRef = React3__namespace.useRef(uncontrolledViewState);
1202
1202
  React3__namespace.useEffect(() => {
1203
1203
  if (!viewState && !defaultViewState) {
1204
- setUncontrolledViewState({
1205
- latitude: firstCoordinate.latitude,
1206
- longitude: firstCoordinate.longitude,
1207
- zoom: calculatedZoom
1204
+ setUncontrolledViewState((prev) => {
1205
+ if (prev.latitude === firstCoordinate.latitude && prev.longitude === firstCoordinate.longitude && prev.zoom === calculatedZoom) {
1206
+ return prev;
1207
+ }
1208
+ return {
1209
+ latitude: firstCoordinate.latitude,
1210
+ longitude: firstCoordinate.longitude,
1211
+ zoom: calculatedZoom
1212
+ };
1208
1213
  });
1209
1214
  }
1210
- }, [firstCoordinate, calculatedZoom, viewState, defaultViewState]);
1215
+ }, [
1216
+ // Use primitive values instead of objects to avoid reference changes
1217
+ firstCoordinate.latitude,
1218
+ firstCoordinate.longitude,
1219
+ calculatedZoom,
1220
+ viewState,
1221
+ defaultViewState
1222
+ ]);
1211
1223
  const isControlledViewState = viewState !== void 0;
1212
1224
  const resolvedViewState = isControlledViewState ? viewState : uncontrolledViewState;
1213
1225
  React3__namespace.useEffect(() => {
1214
1226
  viewStateRef.current = resolvedViewState || uncontrolledViewState;
1215
- }, [resolvedViewState, uncontrolledViewState]);
1227
+ }, [
1228
+ // Use primitive values to avoid reference changes
1229
+ resolvedViewState?.latitude,
1230
+ resolvedViewState?.longitude,
1231
+ resolvedViewState?.zoom,
1232
+ uncontrolledViewState.latitude,
1233
+ uncontrolledViewState.longitude,
1234
+ uncontrolledViewState.zoom
1235
+ ]);
1216
1236
  const applyViewState = React3__namespace.useCallback(
1217
1237
  (nextState) => {
1218
1238
  if (!isControlledViewState) {
@@ -1251,7 +1271,13 @@ function GeoMap({
1251
1271
  setSelection({ type: "none" });
1252
1272
  onSelectionChange?.({ type: "none" });
1253
1273
  }
1254
- }, [onSelectionChange, selectedMarker, selection]);
1274
+ }, [
1275
+ // Use primitive values to avoid object reference issues
1276
+ selection.type,
1277
+ selection.markerId,
1278
+ selectedMarker?.id,
1279
+ onSelectionChange
1280
+ ]);
1255
1281
  const emitSelectionChange = React3__namespace.useCallback(
1256
1282
  (nextSelection) => {
1257
1283
  if (nextSelection.type === "none") {