Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from May 8, 2023

Conversation

dwelle
Copy link
Member

@dwelle dwelle commented May 5, 2023

This PR fixes types: we are stripping (ignoring) some unused AppState props when memoizing LayerUI, but still had all the components operate with the full AppState. That means if we started using those props, it'd introduce stale state bugs.

And we make all the LayerUI compos use/subscribe on the actual AppState subset that we memoize on. This reduces rerenders.

@vercel
Copy link

vercel bot commented May 5, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
excalidraw ✅ Ready (Inspect) Visit Preview May 5, 2023 0:18am
excalidraw-package-example ✅ Ready (Inspect) Visit Preview May 5, 2023 0:18am
1 Ignored Deployment
Name Status Preview Updated (UTC)
docs ⬜️ Ignored (Inspect) May 5, 2023 0:18am

Comment on lines +153 to +154
// FIXME once we split UI canvas from element canvas
appState as AppState,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't matter now (as it's not actually any change in code, just types), and we will be splitting the canvas hopefully soon (the PR in in progress).

An alternative is to pass a getAppState() getter into LayerUI compo.

@dwelle dwelle requested a review from ad1992 May 5, 2023 14:52
@dwelle
Copy link
Member Author

dwelle commented May 8, 2023

🍉

@dwelle dwelle merged commit 560231d into master May 8, 2023
8 checks passed
@dwelle dwelle deleted the dwelle/ui-state-optim branch May 8, 2023 08:14
alswl pushed a commit to alswl/excalidraw that referenced this pull request Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants