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

@ -7,8 +7,9 @@ import {
import { DEFAULT_VERSION } from "../constants";
import { t } from "../i18n";
import { copyTextToSystemClipboard } from "../clipboard";
import { AppState } from "../types";
import { NonDeletedExcalidrawElement } from "../element/types";
import { UIAppState } from "../types";
type StorageSizes = { scene: number; total: number };
const STORAGE_SIZE_TIMEOUT = 500;
@ -23,7 +24,7 @@ const getStorageSizes = debounce((cb: (sizes: StorageSizes) => void) => {
type Props = {
setToast: (message: string) => void;
elements: readonly NonDeletedExcalidrawElement[];
appState: AppState;
appState: UIAppState;
};
const CustomStats = (props: Props) => {
const [storageSizes, setStorageSizes] = useState<StorageSizes>({