Fix performance issue from changing map state

This commit is contained in:
Mitchell McCaffrey
2020-05-19 16:33:23 +10:00
parent 7b98370e4c
commit dbc3cd83e7
4 changed files with 19 additions and 6 deletions

View File

@@ -1,12 +1,22 @@
import React, { useState } from "react";
import React, { useState, useContext } from "react";
import { IconButton } from "theme-ui";
import SelectMapModal from "../../modals/SelectMapModal";
import SelectMapIcon from "../../icons/SelectMapIcon";
function SelectMapButton({ onMapChange, onMapStateChange, currentMap }) {
import MapDataContext from "../../contexts/MapDataContext";
function SelectMapButton({
onMapChange,
onMapStateChange,
currentMap,
currentMapState,
}) {
const [isModalOpen, setIsModalOpen] = useState(false);
const { updateMapState } = useContext(MapDataContext);
function openModal() {
currentMapState && updateMapState(currentMapState.mapId, currentMapState);
setIsModalOpen(true);
}
function closeModal() {