Просмотр исходного кода

Fixing a bug in usePano related to object equality

Kirk Trombley 5 лет назад
Родитель
Сommit
5a23d866d7
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      client/src/components/screens/GamePanel/usePano.jsx

+ 3 - 2
client/src/components/screens/GamePanel/usePano.jsx

@@ -3,6 +3,7 @@ import { useRef, useEffect } from "react";
 
 export default (panoDivRef, position) => {
   const panoRef = useRef(null);
+  const { lat, lng } = position;
   useEffect(() => {
     if (panoRef.current) {
       console.log("Attempted to create a new Pano");
@@ -10,13 +11,13 @@ export default (panoDivRef, position) => {
     }
 
     panoRef.current = new google.maps.StreetViewPanorama(panoDivRef.current, {
-      position,
+      position: { lat, lng },
       addressControl: false,
       showRoadLabels: false,
       clickToGo: true,
       visible: true,
     });
-  }, [panoDivRef, position]);
+  }, [panoDivRef, lat, lng]);
 
   return panoRef;
 }