@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.
@@ -1142,18 +1142,38 @@ function GeoMap({
1142
1142
  const viewStateRef = React3.useRef(uncontrolledViewState);
1143
1143
  React3.useEffect(() => {
1144
1144
  if (!viewState && !defaultViewState) {
1145
- setUncontrolledViewState({
1146
- latitude: firstCoordinate.latitude,
1147
- longitude: firstCoordinate.longitude,
1148
- zoom: calculatedZoom
1145
+ setUncontrolledViewState((prev) => {
1146
+ if (prev.latitude === firstCoordinate.latitude && prev.longitude === firstCoordinate.longitude && prev.zoom === calculatedZoom) {
1147
+ return prev;
1148
+ }
1149
+ return {
1150
+ latitude: firstCoordinate.latitude,
1151
+ longitude: firstCoordinate.longitude,
1152
+ zoom: calculatedZoom
1153
+ };
1149
1154
  });
1150
1155
  }
1151
- }, [firstCoordinate, calculatedZoom, viewState, defaultViewState]);
1156
+ }, [
1157
+ // Use primitive values instead of objects to avoid reference changes
1158
+ firstCoordinate.latitude,
1159
+ firstCoordinate.longitude,
1160
+ calculatedZoom,
1161
+ viewState,
1162
+ defaultViewState
1163
+ ]);
1152
1164
  const isControlledViewState = viewState !== void 0;
1153
1165
  const resolvedViewState = isControlledViewState ? viewState : uncontrolledViewState;
1154
1166
  React3.useEffect(() => {
1155
1167
  viewStateRef.current = resolvedViewState || uncontrolledViewState;
1156
- }, [resolvedViewState, uncontrolledViewState]);
1168
+ }, [
1169
+ // Use primitive values to avoid reference changes
1170
+ resolvedViewState?.latitude,
1171
+ resolvedViewState?.longitude,
1172
+ resolvedViewState?.zoom,
1173
+ uncontrolledViewState.latitude,
1174
+ uncontrolledViewState.longitude,
1175
+ uncontrolledViewState.zoom
1176
+ ]);
1157
1177
  const applyViewState = React3.useCallback(
1158
1178
  (nextState) => {
1159
1179
  if (!isControlledViewState) {
@@ -1192,7 +1212,13 @@ function GeoMap({
1192
1212
  setSelection({ type: "none" });
1193
1213
  onSelectionChange?.({ type: "none" });
1194
1214
  }
1195
- }, [onSelectionChange, selectedMarker, selection]);
1215
+ }, [
1216
+ // Use primitive values to avoid object reference issues
1217
+ selection.type,
1218
+ selection.markerId,
1219
+ selectedMarker?.id,
1220
+ onSelectionChange
1221
+ ]);
1196
1222
  const emitSelectionChange = React3.useCallback(
1197
1223
  (nextSelection) => {
1198
1224
  if (nextSelection.type === "none") {