From 824202d3a6ead0566a55efae29c4176f63fd0d86 Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Mon, 14 Mar 2022 21:59:03 -0400 Subject: [PATCH] Fix rendering fetchedPlugin cells on initial load --- components/Map.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/Map.tsx b/components/Map.tsx index 28f115c..98dc406 100644 --- a/components/Map.tsx +++ b/components/Map.tsx @@ -4,8 +4,8 @@ import Gradient from "javascript-color-gradient"; import mapboxgl from "mapbox-gl"; import useSWRImmutable from "swr/immutable"; -import { useAppDispatch, useAppSelector } from "../lib/hooks"; -import { PluginFile, setFetchedPlugin } from "../slices/plugins"; +import { useAppSelector } from "../lib/hooks"; +import { PluginFile } from "../slices/plugins"; import styles from "../styles/Map.module.css"; import Sidebar from "./Sidebar"; import ToggleLayersControl from "./ToggleLayersControl"; @@ -59,7 +59,6 @@ const Map: React.FC = () => { | null >(null); const [sidebarOpen, setSidebarOpen] = useState(true); - const dispatch = useAppDispatch(); const plugins = useAppSelector((state) => state.plugins.plugins); const pluginsPending = useAppSelector((state) => state.plugins.pending); @@ -362,6 +361,7 @@ const Map: React.FC = () => { ]); useEffect(() => { + if (!heatmapLoaded) return; // wait for all map layers to load if ( router.query.plugin && typeof router.query.plugin === "string" && @@ -382,7 +382,7 @@ const Map: React.FC = () => { } selectCells(cells); } - }, [fetchedPlugin, selectCells, router.query.plugin]); + }, [heatmapLoaded, fetchedPlugin, selectCells, router.query.plugin]); useEffect(() => { if (!heatmapLoaded) return; // wait for all map layers to load