-
Notifications
You must be signed in to change notification settings - Fork 432
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
fix: improve presence menu performance #8039
base: add-million-lint-mode
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
No changes to documentation |
Component Testing Report Updated Dec 13, 2024 2:51 PM (UTC) ❌ Failed Tests (7) -- expand for details
|
⚡️ Editor Performance ReportUpdated Fri, 13 Dec 2024 14:55:18 GMT
Detailed information🏠 Reference resultThe performance result of
🧪 Experiment resultThe performance result of this branch
📚 Glossary
|
const LinkComponent = useMemo( | ||
() => | ||
// eslint-disable-next-line @typescript-eslint/no-shadow | ||
forwardRef(function LinkComponent(linkProps, ref: ForwardedRef<HTMLAnchorElement>) { | ||
if (!lastActiveLocation?.path) return null | ||
|
||
return ( | ||
<IntentLink | ||
{...linkProps} | ||
intent="edit" | ||
params={{ | ||
id: lastActiveLocation?.documentId, | ||
path: PathUtils.toString(lastActiveLocation?.path), | ||
}} | ||
ref={ref} | ||
/> | ||
) | ||
}), | ||
[lastActiveLocation], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason React Compiler bails out of this component here.
I tried removing the useMemo
to leave it to the compiler how to memoize it, and the bug was still there.
Turns out the problem is that defining components inline like this isn't a supported pattern.
By refactoring <MenuItem>
to use a stable as
prop to IntentLink
, and give it props and live it to styled-components
to forward props, it works with the compiler as well.
Description
Fixes a performance issue in
<PresenceMenuItem />
causing edit intent links to constantly unmount and mount new dom nodes on every single render.What to review
Does it make sense?
Testing
Tested manually, verified with
pnpm dev:million-lint
that the issue is resolved.Notes for release
Links in the global presence dropdown menu had a bug that caused nodes to constantly unmount and remount, slowing down exponentially with how many people are in the studio at the same time. It now renders efficiently.