Fix performance issue from changing map state
This commit is contained in:
@@ -286,6 +286,7 @@ function Map({
|
||||
onMapChange={onMapChange}
|
||||
onMapStateChange={onMapStateChange}
|
||||
currentMap={map}
|
||||
currentMapState={mapState}
|
||||
onSelectedToolChange={setSelectedToolId}
|
||||
selectedToolId={selectedToolId}
|
||||
toolSettings={toolSettings}
|
||||
|
||||
@@ -22,6 +22,7 @@ function MapContols({
|
||||
onMapChange,
|
||||
onMapStateChange,
|
||||
currentMap,
|
||||
currentMapState,
|
||||
selectedToolId,
|
||||
onSelectedToolChange,
|
||||
toolSettings,
|
||||
@@ -73,6 +74,7 @@ function MapContols({
|
||||
onMapChange={onMapChange}
|
||||
onMapStateChange={onMapStateChange}
|
||||
currentMap={currentMap}
|
||||
currentMapState={currentMapState}
|
||||
/>
|
||||
),
|
||||
},
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user