mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
do not re-render static when setting selected element ids in lasso
This commit is contained in:
parent
1e1dab3bbc
commit
64aeb0fe56
2 changed files with 42 additions and 26 deletions
|
@ -89,7 +89,10 @@ const StaticCanvas = (props: StaticCanvasProps) => {
|
||||||
|
|
||||||
const getRelevantAppStateProps = (
|
const getRelevantAppStateProps = (
|
||||||
appState: AppState,
|
appState: AppState,
|
||||||
): StaticCanvasAppState => ({
|
):
|
||||||
|
| StaticCanvasAppState
|
||||||
|
| Omit<StaticCanvasAppState, "selectedElementIds" | "activeTool"> => {
|
||||||
|
const relevantAppStateProps = {
|
||||||
zoom: appState.zoom,
|
zoom: appState.zoom,
|
||||||
scrollX: appState.scrollX,
|
scrollX: appState.scrollX,
|
||||||
scrollY: appState.scrollY,
|
scrollY: appState.scrollY,
|
||||||
|
@ -114,7 +117,18 @@ const getRelevantAppStateProps = (
|
||||||
editingGroupId: appState.editingGroupId,
|
editingGroupId: appState.editingGroupId,
|
||||||
currentHoveredFontFamily: appState.currentHoveredFontFamily,
|
currentHoveredFontFamily: appState.currentHoveredFontFamily,
|
||||||
croppingElementId: appState.croppingElementId,
|
croppingElementId: appState.croppingElementId,
|
||||||
});
|
activeTool: appState.activeTool,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (appState.activeTool.type === "lasso") {
|
||||||
|
delete (relevantAppStateProps as Partial<typeof relevantAppStateProps>)
|
||||||
|
.activeTool;
|
||||||
|
delete (relevantAppStateProps as Partial<typeof relevantAppStateProps>)
|
||||||
|
.selectedElementIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
return relevantAppStateProps;
|
||||||
|
};
|
||||||
|
|
||||||
const areEqual = (
|
const areEqual = (
|
||||||
prevProps: StaticCanvasProps,
|
prevProps: StaticCanvasProps,
|
||||||
|
|
|
@ -203,6 +203,8 @@ export type StaticCanvasAppState = Readonly<
|
||||||
hoveredElementIds: AppState["hoveredElementIds"];
|
hoveredElementIds: AppState["hoveredElementIds"];
|
||||||
// Cropping
|
// Cropping
|
||||||
croppingElementId: AppState["croppingElementId"];
|
croppingElementId: AppState["croppingElementId"];
|
||||||
|
// For reducing unnecessary re-renders
|
||||||
|
activeTool: AppState["activeTool"];
|
||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue