Skip to content

Commit

Permalink
fix: 이벤트 해제 클리어 함수 수정 #222
Browse files Browse the repository at this point in the history
  • Loading branch information
1119wj committed Dec 3, 2024
1 parent bc406f7 commit 23a58a1
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions frontend/src/hooks/useMarker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@ export const useMarker = (props: MarkerProps) => {
newMarker.map = map;
setMarker(newMarker);
addMarker(newMarker);
console.log(newMarker, 'add new marker');

return () => {
newMarker.map = null;
setMarker(null);
google.maps.event.clearInstanceListeners(newMarker);
removeMarker(newMarker);
};
}, [map, order]);
Expand All @@ -90,14 +89,10 @@ export const useMarker = (props: MarkerProps) => {
infoWindow.open({ anchor: marker, map });
moveTo(position?.lat as number, position?.lng as number);
});

google.maps.event.addListener(map, 'click', () => {
infoWindow.close();
});

return () => {
google.maps.event.clearInstanceListeners(marker);
google.maps.event.clearInstanceListeners(map);
};
}, [marker, onClick]);
return marker;
};
Expand Down

0 comments on commit 23a58a1

Please sign in to comment.