[composite] Remove unnecessary props memos#5023
Open
atomiks wants to merge 2 commits into
Open
Conversation
033b02a to
d22c5aa
Compare
commit: |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Bundle size
PerformanceTotal duration: 1,126.88 ms -117.21 ms(-9.4%) | Renders: 50 (+0) | Paint: 1,712.47 ms -166.05 ms(-8.8%)
11 tests within noise — details Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
# Conflicts: # packages/react/src/internals/composite/root/useCompositeRoot.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
propsobject returned byuseCompositeRootis consumed only byCompositeRoot, which passes it intouseRenderElement→mergeProps— re-merged unconditionally every render, so the object's identity is never compared. The memo's ~15-entry dep array includedhighlightedIndex, so it invalidated on every arrow-key navigation anyway, and was pure maintenance burden with stale-closure risk.useCompositeRoot: the props object is now created per render.onKeyDownis wrapped inuseStableCallbackbecause its identity (asrelayKeyboardEvent) does matter: it flows into theCompositeRootContextvalue memo and intouseTriggerDataForwarding's effect deps viaObject.values(stateUpdates). It's now fully stable, where previously it changed on every navigation.useCompositeRoot: the return-value memo is also removed —CompositeRootis the only consumer and destructures it immediately.useCompositeItem:compositePropsmemo removed — both consumers (CompositeItem,TabsTab) only pass it intouseRenderElementprops arrays.useCompositeListItem: return-value memo removed — all consumers only access.ref(alreadyuseCallback'd, identity unchanged) and.index; the wrapper object identity is never used.Tests:
Composite(jsdom + Chromium),TabsandMenubar(jsdom) all pass;pnpm typescriptand eslint clean.