From 741602dff59d54b084180a16728d9995b6768ef8 Mon Sep 17 00:00:00 2001
From: Yuval Adam <_@yuv.al>
Date: Thu, 1 Sep 2022 17:35:06 +0300
Subject: Skip slider renders on empty images, and cleanup unused vars

---
 src/Map.tsx | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

(limited to 'src/Map.tsx')

diff --git a/src/Map.tsx b/src/Map.tsx
index 590f80d..39f28fa 100644
--- a/src/Map.tsx
+++ b/src/Map.tsx
@@ -19,9 +19,9 @@ export function Map({ slider, images }: MapProps) {
   const mapContainer = useRef(null);
   const map = useRef<mapboxgl.Map>(null);
 
-  const [lng, setLng] = useState(35);
-  const [lat, setLat] = useState(31.9);
-  const [zoom, setZoom] = useState(6.3);
+  const [lng] = useState(35);
+  const [lat] = useState(31.9);
+  const [zoom] = useState(6.3);
   const [loaded, setLoaded] = useState(false);
 
   const prevImages = useRef(images).current;
@@ -80,7 +80,7 @@ export function Map({ slider, images }: MapProps) {
   }, [loaded, prevImages, images]);
 
   useEffect(() => {
-    if (!loaded) return;
+    if (!loaded || !images.length) return;
     images[slider] && map.current.setPaintProperty(`layer-${images[slider]}`, "raster-opacity", 0.85);
     return () => {
       // callback will hide the previous layer with the previous slider value
-- 
cgit v1.3.1

