Compare commits

...

4 Commits

Author SHA1 Message Date
Daniel J. Geiger
a07ac46f8d Revert "fix: React.memo resolvers not accounting for all props (#6042)"
This reverts commit 618442299f.
2023-01-19 20:03:09 -06:00
Daniel J. Geiger
157bb7d6d6 Do not merge. 2023-01-19 19:44:52 -06:00
David Luzar
d0b33d35db build: temporarily disable pre-commit (#6132) 2023-01-19 13:50:42 +01:00
Aakansha Doshi
d6a5ef1936 docs: release @excalidraw/excalidraw@0.14.1 🎉 (#6112) 2023-01-16 16:08:03 +05:30
7 changed files with 37 additions and 54 deletions

View File

@@ -1,2 +1,2 @@
#!/bin/sh #!/bin/sh
yarn lint-staged # yarn lint-staged

View File

@@ -567,6 +567,7 @@ class App extends React.Component<AppProps, AppState> {
value={this.actionManager} value={this.actionManager}
> >
<LayerUI <LayerUI
test={<div />}
canvas={this.canvas} canvas={this.canvas}
appState={this.state} appState={this.state}
files={this.files} files={this.files}

View File

@@ -16,7 +16,7 @@ import {
UIChildrenComponents, UIChildrenComponents,
UIWelcomeScreenComponents, UIWelcomeScreenComponents,
} from "../types"; } from "../types";
import { isShallowEqual, muteFSAbortError, getReactChildren } from "../utils"; import { muteFSAbortError, getReactChildren } from "../utils";
import { SelectedShapeActions, ShapesSwitcher } from "./Actions"; import { SelectedShapeActions, ShapesSwitcher } from "./Actions";
import { ErrorDialog } from "./ErrorDialog"; import { ErrorDialog } from "./ErrorDialog";
import { ExportCB, ImageExportDialog } from "./ImageExportDialog"; import { ExportCB, ImageExportDialog } from "./ImageExportDialog";
@@ -52,6 +52,7 @@ import { useAtom } from "jotai";
import MainMenu from "./main-menu/MainMenu"; import MainMenu from "./main-menu/MainMenu";
interface LayerUIProps { interface LayerUIProps {
test: JSX.Element;
actionManager: ActionManager; actionManager: ActionManager;
appState: AppState; appState: AppState;
files: BinaryFiles; files: BinaryFiles;
@@ -479,39 +480,28 @@ const LayerUI = ({
); );
}; };
const stripIrrelevantAppStateProps = ( const areEqual = (prev: LayerUIProps, next: LayerUIProps) => {
appState: AppState, const getNecessaryObj = (appState: AppState): Partial<AppState> => {
): Partial<AppState> => { const {
const { suggestedBindings, startBoundElement, cursorButton, ...ret } = suggestedBindings,
appState; startBoundElement: boundElement,
return ret; ...ret
}; } = appState;
return ret;
};
const prevAppState = getNecessaryObj(prev.appState);
const nextAppState = getNecessaryObj(next.appState);
const areEqual = (prevProps: LayerUIProps, nextProps: LayerUIProps) => { const keys = Object.keys(prevAppState) as (keyof Partial<AppState>)[];
// short-circuit early
if (prevProps.children !== nextProps.children) {
return false;
}
const {
canvas: _prevCanvas,
// not stable, but shouldn't matter in our case
onInsertElements: _prevOnInsertElements,
appState: prevAppState,
...prev
} = prevProps;
const {
canvas: _nextCanvas,
onInsertElements: _nextOnInsertElements,
appState: nextAppState,
...next
} = nextProps;
return ( return (
isShallowEqual( prev.renderTopRightUI === next.renderTopRightUI &&
stripIrrelevantAppStateProps(prevAppState), prev.renderCustomStats === next.renderCustomStats &&
stripIrrelevantAppStateProps(nextAppState), prev.renderCustomSidebar === next.renderCustomSidebar &&
) && isShallowEqual(prev, next) prev.langCode === next.langCode &&
prev.elements === next.elements &&
prev.files === next.files &&
keys.every((key) => prevAppState[key] === nextAppState[key])
); );
}; };

View File

@@ -11,6 +11,12 @@ The change should be grouped under one of the below section and must contain PR
Please add the latest change on the top under the correct section. Please add the latest change on the top under the correct section.
--> -->
## 0.14.1 (2023-01-16)
### Fixes
- remove overflow hidden from button [#6110](https://github.com/excalidraw/excalidraw/pull/6110). This fixes the collaborator count css in the [LiveCollaborationTrigger](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#LiveCollaborationTrigger) component.
## 0.14.0 (2023-01-13) ## 0.14.0 (2023-01-13)
### Features ### Features
@@ -72,8 +78,6 @@ Please add the latest change on the top under the correct section.
### Fixes ### Fixes
- remove overflow hidden from button [#6110](https://github.com/excalidraw/excalidraw/pull/6110)
- Mobile tools positioning [#6107](https://github.com/excalidraw/excalidraw/pull/6107) - Mobile tools positioning [#6107](https://github.com/excalidraw/excalidraw/pull/6107)
- Renamed folder MainMenu->main-menu and support rest props [#6103](https://github.com/excalidraw/excalidraw/pull/6103) - Renamed folder MainMenu->main-menu and support rest props [#6103](https://github.com/excalidraw/excalidraw/pull/6103)

View File

@@ -1,7 +1,6 @@
import React, { useEffect, forwardRef } from "react"; import React, { useEffect, forwardRef } from "react";
import { InitializeApp } from "../../components/InitializeApp"; import { InitializeApp } from "../../components/InitializeApp";
import App from "../../components/App"; import App from "../../components/App";
import { isShallowEqual } from "../../utils";
import "../../css/app.scss"; import "../../css/app.scss";
import "../../css/styles.scss"; import "../../css/styles.scss";
@@ -130,11 +129,6 @@ const areEqual = (
prevProps: PublicExcalidrawProps, prevProps: PublicExcalidrawProps,
nextProps: PublicExcalidrawProps, nextProps: PublicExcalidrawProps,
) => { ) => {
// short-circuit early
if (prevProps.children !== nextProps.children) {
return false;
}
const { const {
initialData: prevInitialData, initialData: prevInitialData,
UIOptions: prevUIOptions = {}, UIOptions: prevUIOptions = {},
@@ -183,7 +177,13 @@ const areEqual = (
return prevUIOptions[key] === nextUIOptions[key]; return prevUIOptions[key] === nextUIOptions[key];
}); });
return isUIOptionsSame && isShallowEqual(prev, next); const prevKeys = Object.keys(prevProps) as (keyof typeof prev)[];
const nextKeys = Object.keys(nextProps) as (keyof typeof next)[];
return (
isUIOptionsSame &&
prevKeys.length === nextKeys.length &&
prevKeys.every((key) => prev[key] === next[key])
);
}; };
const forwardedRefComp = forwardRef< const forwardedRefComp = forwardRef<

View File

@@ -1,6 +1,6 @@
{ {
"name": "@excalidraw/excalidraw", "name": "@excalidraw/excalidraw",
"version": "0.14.0", "version": "0.14.1",
"main": "main.js", "main": "main.js",
"types": "types/packages/excalidraw/index.d.ts", "types": "types/packages/excalidraw/index.d.ts",
"files": [ "files": [

View File

@@ -728,15 +728,3 @@ export const getReactChildren = <
return [knownChildren, restChildren] as const; return [knownChildren, restChildren] as const;
}; };
export const isShallowEqual = <T extends Record<string, any>>(
objA: T,
objB: T,
) => {
const aKeys = Object.keys(objA);
const bKeys = Object.keys(objA);
if (aKeys.length !== bKeys.length) {
return false;
}
return aKeys.every((key) => objA[key] === objB[key]);
};