perf: use UIAppState
where possible to reduce UI rerenders (#6560)
This commit is contained in:
19
src/types.ts
19
src/types.ts
@ -1,3 +1,4 @@
|
||||
import React from "react";
|
||||
import {
|
||||
PointerType,
|
||||
ExcalidrawLinearElement,
|
||||
@ -32,7 +33,6 @@ import type { FileSystemHandle } from "./data/filesystem";
|
||||
import type { IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
|
||||
import { ContextMenuItems } from "./components/ContextMenu";
|
||||
import { Merge, ForwardRef, ValueOf } from "./utility-types";
|
||||
import React from "react";
|
||||
|
||||
export type Point = Readonly<RoughPoint>;
|
||||
|
||||
@ -218,6 +218,15 @@ export type AppState = {
|
||||
selectedLinearElement: LinearElementEditor | null;
|
||||
};
|
||||
|
||||
export type UIAppState = Omit<
|
||||
AppState,
|
||||
| "suggestedBindings"
|
||||
| "startBoundElement"
|
||||
| "cursorButton"
|
||||
| "scrollX"
|
||||
| "scrollY"
|
||||
>;
|
||||
|
||||
export type NormalizedZoomValue = number & { _brand: "normalizedZoom" };
|
||||
|
||||
export type Zoom = Readonly<{
|
||||
@ -314,7 +323,7 @@ export interface ExcalidrawProps {
|
||||
) => Promise<boolean> | boolean;
|
||||
renderTopRightUI?: (
|
||||
isMobile: boolean,
|
||||
appState: AppState,
|
||||
appState: UIAppState,
|
||||
) => JSX.Element | null;
|
||||
langCode?: Language["code"];
|
||||
viewModeEnabled?: boolean;
|
||||
@ -325,7 +334,7 @@ export interface ExcalidrawProps {
|
||||
name?: string;
|
||||
renderCustomStats?: (
|
||||
elements: readonly NonDeletedExcalidrawElement[],
|
||||
appState: AppState,
|
||||
appState: UIAppState,
|
||||
) => JSX.Element;
|
||||
UIOptions?: Partial<UIOptions>;
|
||||
detectScroll?: boolean;
|
||||
@ -364,13 +373,13 @@ export type ExportOpts = {
|
||||
saveFileToDisk?: boolean;
|
||||
onExportToBackend?: (
|
||||
exportedElements: readonly NonDeletedExcalidrawElement[],
|
||||
appState: AppState,
|
||||
appState: UIAppState,
|
||||
files: BinaryFiles,
|
||||
canvas: HTMLCanvasElement | null,
|
||||
) => void;
|
||||
renderCustomUI?: (
|
||||
exportedElements: readonly NonDeletedExcalidrawElement[],
|
||||
appState: AppState,
|
||||
appState: UIAppState,
|
||||
files: BinaryFiles,
|
||||
canvas: HTMLCanvasElement | null,
|
||||
) => JSX.Element;
|
||||
|
Reference in New Issue
Block a user