@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.js CHANGED
@@ -1180,18 +1180,38 @@ function GeoMap({
1180
1180
  const viewStateRef = React3.useRef(uncontrolledViewState);
1181
1181
  React3.useEffect(() => {
1182
1182
  if (!viewState && !defaultViewState) {
1183
- setUncontrolledViewState({
1184
- latitude: firstCoordinate.latitude,
1185
- longitude: firstCoordinate.longitude,
1186
- zoom: calculatedZoom
1183
+ setUncontrolledViewState((prev) => {
1184
+ if (prev.latitude === firstCoordinate.latitude && prev.longitude === firstCoordinate.longitude && prev.zoom === calculatedZoom) {
1185
+ return prev;
1186
+ }
1187
+ return {
1188
+ latitude: firstCoordinate.latitude,
1189
+ longitude: firstCoordinate.longitude,
1190
+ zoom: calculatedZoom
1191
+ };
1187
1192
  });
1188
1193
  }
1189
- }, [firstCoordinate, calculatedZoom, viewState, defaultViewState]);
1194
+ }, [
1195
+ // Use primitive values instead of objects to avoid reference changes
1196
+ firstCoordinate.latitude,
1197
+ firstCoordinate.longitude,
1198
+ calculatedZoom,
1199
+ viewState,
1200
+ defaultViewState
1201
+ ]);
1190
1202
  const isControlledViewState = viewState !== void 0;
1191
1203
  const resolvedViewState = isControlledViewState ? viewState : uncontrolledViewState;
1192
1204
  React3.useEffect(() => {
1193
1205
  viewStateRef.current = resolvedViewState || uncontrolledViewState;
1194
- }, [resolvedViewState, uncontrolledViewState]);
1206
+ }, [
1207
+ // Use primitive values to avoid reference changes
1208
+ resolvedViewState?.latitude,
1209
+ resolvedViewState?.longitude,
1210
+ resolvedViewState?.zoom,
1211
+ uncontrolledViewState.latitude,
1212
+ uncontrolledViewState.longitude,
1213
+ uncontrolledViewState.zoom
1214
+ ]);
1195
1215
  const applyViewState = React3.useCallback(
1196
1216
  (nextState) => {
1197
1217
  if (!isControlledViewState) {
@@ -1230,7 +1250,13 @@ function GeoMap({
1230
1250
  setSelection({ type: "none" });
1231
1251
  onSelectionChange?.({ type: "none" });
1232
1252
  }
1233
- }, [onSelectionChange, selectedMarker, selection]);
1253
+ }, [
1254
+ // Use primitive values to avoid object reference issues
1255
+ selection.type,
1256
+ selection.markerId,
1257
+ selectedMarker?.id,
1258
+ onSelectionChange
1259
+ ]);
1234
1260
  const emitSelectionChange = React3.useCallback(
1235
1261
  (nextSelection) => {
1236
1262
  if (nextSelection.type === "none") {