-
Notifications
You must be signed in to change notification settings - Fork 604
Improve PageLayout performance #5942
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
Conversation
🦋 Changeset detectedLatest commit: fd2ae7a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Pull Request Overview
Improve PageLayout performance by reducing unnecessary re-renders caused by the re-creation of objects and functions.
- Wrapped enableStickyPane and disableStickyPane in React.useCallback in useStickyPaneHeight for consistent references.
- Introduced memoization of the context value in PageLayout to prevent needless re-renders of consumers.
- Added a changeset for a patch release.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
packages/react/src/PageLayout/useStickyPaneHeight.ts | Introduces useCallback wrappers and memoizes the hook's returned object. |
packages/react/src/PageLayout/PageLayout.tsx | Uses React.useMemo for the context value to reduce re-rendering overhead. |
.changeset/clean-fried-eggs.md | Provides a changeset for the patch release focused on performance improvements. |
👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks! |
size-limit report 📦
|
Uh oh! @hectahertz, at least one image you shared is missing helpful alt text. Check your pull request body to fix the following violations:
Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image. Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.
|
9ff343f
to
fd2ae7a
Compare
Closes #4591
Changelog
Changed
Fixes the extra re-renders caused by the
useStickyPaneHeight
hook onPageLayout
and its contents.The cause of the re-renders was re-creation of objects and functions on every hook call, which cause the context consumers to re-render.
Further improvements could (and should) be made by:
Before:
Screen.Recording.2025-04-20.at.16.03.25.mov
After:
Screen.Recording.2025-04-20.at.16.01.59.mov
Rollout strategy
Testing & Reviewing
Merge checklist