summaryrefslogtreecommitdiff
path: root/src/Map.tsx
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2022-09-01 17:35:06 +0300
committerYuval Adam <_@yuv.al>2022-09-01 17:35:06 +0300
commit741602dff59d54b084180a16728d9995b6768ef8 (patch)
tree707ae0173209e7fc0b67dd80c27dcc3b829b1345 /src/Map.tsx
parente588e0f41e26353dd5425150225817cc52fab4bf (diff)
Skip slider renders on empty images, and cleanup unused vars
Diffstat (limited to 'src/Map.tsx')
-rw-r--r--src/Map.tsx8
1 files changed, 4 insertions, 4 deletions
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