Skip to content

Commit

Permalink
fix: add use memo to function returning zoomLevels
Browse files Browse the repository at this point in the history
  • Loading branch information
mulengawilfred committed Dec 5, 2024
1 parent 508434f commit a7d0538
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/engines/Cesium/core/Imagery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ export function useImageryProviders({
const tileKeys = tiles.map(t => t.id).join(",");
const prevTileKeys = useRef(tileKeys);
const prevProviders = useRef<Providers>({});

const zoomLevels = tiles.map(t => {
if(t.id && t.zoomLevel) return {[t.id]: t.zoomLevel}
const zoomLevels = useMemo(() => tiles.map(t => {
if (t.id && t.zoomLevel) return { [t.id]: t.zoomLevel };
return
})
const prevZoomLevels = useRef(zoomLevels)
}),
[tiles]);
const prevZoomLevels = useRef(zoomLevels);

// Manage TileProviders so that TileProvider does not need to be recreated each time tiles are updated.
const { providers, updated } = useMemo(() => {
Expand Down

0 comments on commit a7d0538

Please sign in to comment.