@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.
@@ -1163,18 +1163,38 @@ function GeoMap({
1163
1163
  const viewStateRef = React3__namespace.useRef(uncontrolledViewState);
1164
1164
  React3__namespace.useEffect(() => {
1165
1165
  if (!viewState && !defaultViewState) {
1166
- setUncontrolledViewState({
1167
- latitude: firstCoordinate.latitude,
1168
- longitude: firstCoordinate.longitude,
1169
- zoom: calculatedZoom
1166
+ setUncontrolledViewState((prev) => {
1167
+ if (prev.latitude === firstCoordinate.latitude && prev.longitude === firstCoordinate.longitude && prev.zoom === calculatedZoom) {
1168
+ return prev;
1169
+ }
1170
+ return {
1171
+ latitude: firstCoordinate.latitude,
1172
+ longitude: firstCoordinate.longitude,
1173
+ zoom: calculatedZoom
1174
+ };
1170
1175
  });
1171
1176
  }
1172
- }, [firstCoordinate, calculatedZoom, viewState, defaultViewState]);
1177
+ }, [
1178
+ // Use primitive values instead of objects to avoid reference changes
1179
+ firstCoordinate.latitude,
1180
+ firstCoordinate.longitude,
1181
+ calculatedZoom,
1182
+ viewState,
1183
+ defaultViewState
1184
+ ]);
1173
1185
  const isControlledViewState = viewState !== void 0;
1174
1186
  const resolvedViewState = isControlledViewState ? viewState : uncontrolledViewState;
1175
1187
  React3__namespace.useEffect(() => {
1176
1188
  viewStateRef.current = resolvedViewState || uncontrolledViewState;
1177
- }, [resolvedViewState, uncontrolledViewState]);
1189
+ }, [
1190
+ // Use primitive values to avoid reference changes
1191
+ resolvedViewState?.latitude,
1192
+ resolvedViewState?.longitude,
1193
+ resolvedViewState?.zoom,
1194
+ uncontrolledViewState.latitude,
1195
+ uncontrolledViewState.longitude,
1196
+ uncontrolledViewState.zoom
1197
+ ]);
1178
1198
  const applyViewState = React3__namespace.useCallback(
1179
1199
  (nextState) => {
1180
1200
  if (!isControlledViewState) {
@@ -1213,7 +1233,13 @@ function GeoMap({
1213
1233
  setSelection({ type: "none" });
1214
1234
  onSelectionChange?.({ type: "none" });
1215
1235
  }
1216
- }, [onSelectionChange, selectedMarker, selection]);
1236
+ }, [
1237
+ // Use primitive values to avoid object reference issues
1238
+ selection.type,
1239
+ selection.markerId,
1240
+ selectedMarker?.id,
1241
+ onSelectionChange
1242
+ ]);
1217
1243
  const emitSelectionChange = React3__namespace.useCallback(
1218
1244
  (nextSelection) => {
1219
1245
  if (nextSelection.type === "none") {