-
Notifications
You must be signed in to change notification settings - Fork 186
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
I am using the Cluster example the docs with MarkerWithInfoWindow, however there is nothing much i changed for cluster or infowindow from the docs... onClick on the marker should have open the infowindow, but instead to goes in an infinite loop.
Please note that i am setting the markerRef(marker); on the ref of AdvanceMarker manually because i want to support Cluster along with it... it appears to be a standard way to me to set ref to multiple places for marker... however it crashes
const MarkerWithInfoWindow = forwardRef<
AdvancedMarkerRef,
AdvancedMarkerProps & {
point: Point;
setMarkerRef: (marker: Marker | null, key: number) => void;
}
>(({ point, setMarkerRef, ...props }, ref) => {
let [markerRef, marker] = useAdvancedMarkerRef();
const [infoWindowOpen, setInfoWindowOpen] = useState(false);
return (
<>
<AdvancedMarker
ref={(marker1) => {
markerRef(marker1);
setMarkerRef(marker1, point.key);
}}
onClick={(e) => {
setInfoWindowOpen(true);
}}
position={point}
title={point.name}
zIndex={50}
{...props}
/>
{infoWindowOpen && (
<InfoWindow anchor={marker} maxWidth={200} onCloseClick={() => setInfoWindowOpen(false)}>
<code style={{ whiteSpace: 'nowrap' }}><AdvancedMarker /></code> combined with an
Infowindow.
</InfoWindow>
)}
</>
);
});Steps to Reproduce
I am using next 14, and this is a client component.
- Click on the marker and it goes on an infinite loop and hence the app crashes.
Environment
- Library version: "@vis.gl/react-google-maps": "^1.0.2",
- Google maps version: 3.57.3a
- Browser and Version: Chrome 125.0.6422.141 (Official Build) (64-bit)
- OS: Linux ( Ubuntu )
Logs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working

