Optimisation to tile rendering

This commit is contained in:
Mitchell McCaffrey
2021-06-10 20:08:11 +10:00
parent fa8d081079
commit 4bfe49f454
6 changed files with 33 additions and 16 deletions

View File

@@ -221,6 +221,16 @@ export function MapDataProvider({ children }) {
};
}, [database, databaseStatus]);
const [mapsById, setMapsById] = useState({});
useEffect(() => {
setMapsById(
maps.reduce((obj, map) => {
obj[map.id] = map;
return obj;
}, {})
);
}, [maps]);
const value = {
maps,
mapStates,
@@ -234,6 +244,7 @@ export function MapDataProvider({ children }) {
mapsLoading,
getMapState,
updateMapGroups,
mapsById,
};
return (
<MapDataContext.Provider value={value}>{children}</MapDataContext.Provider>