perf: use UIAppState where possible to reduce UI rerenders (#6560)

This commit is contained in:
David Luzar 2023-05-08 10:14:02 +02:00 committed by GitHub
parent 026949204d
commit 560231d365
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 155 additions and 125 deletions

View file

@ -4,11 +4,10 @@ import { canvasToBlob } from "../data/blob";
import { NonDeletedExcalidrawElement } from "../element/types";
import { t } from "../i18n";
import { getSelectedElements, isSomeElementSelected } from "../scene";
import { AppState, BinaryFiles } from "../types";
import { BinaryFiles, UIAppState } from "../types";
import { Dialog } from "./Dialog";
import { clipboard } from "./icons";
import Stack from "./Stack";
import "./ExportDialog.scss";
import OpenColor from "open-color";
import { CheckboxItem } from "./CheckboxItem";
import { DEFAULT_EXPORT_PADDING, isFirefox } from "../constants";
@ -16,6 +15,8 @@ import { nativeFileSystemSupported } from "../data/filesystem";
import { ActionManager } from "../actions/manager";
import { exportToCanvas } from "../packages/utils";
import "./ExportDialog.scss";
const supportsContextFilters =
"filter" in document.createElement("canvas").getContext("2d")!;
@ -70,7 +71,7 @@ const ImageExportModal = ({
onExportToSvg,
onExportToClipboard,
}: {
appState: AppState;
appState: UIAppState;
elements: readonly NonDeletedExcalidrawElement[];
files: BinaryFiles;
exportPadding?: number;
@ -216,8 +217,8 @@ export const ImageExportDialog = ({
onExportToSvg,
onExportToClipboard,
}: {
appState: AppState;
setAppState: React.Component<any, AppState>["setState"];
appState: UIAppState;
setAppState: React.Component<any, UIAppState>["setState"];
elements: readonly NonDeletedExcalidrawElement[];
files: BinaryFiles;
exportPadding?: number;