-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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: Prevent rerenders of the AccountListItem #30873
base: main
Are you sure you want to change the base?
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
90b6a1d
to
0a679f6
Compare
Builds ready [0a679f6]
Page Load Metrics (1772 ± 40 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
export function getInternalAccounts(state: AccountsState) { | ||
return Object.values(state.metamask.internalAccounts.accounts); | ||
} | ||
export const getInternalAccounts = createSelector( |
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.
Very nice work with the createSelector here!
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.
(future) - can we add an equality check to prove that this is not creating a new array, and causing extra rerenders?
it('returns same result with exact same state', () => {
const result1 = getInternalAccounts(state);
const result2 = getInternalAccounts(state);
expect(result1 === result2).toBe(true)
})
72a4090
Builds ready [214cea0]
Page Load Metrics (2051 ± 100 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
214cea0
to
dd2efdb
Compare
Builds ready [dd2efdb]
Page Load Metrics (2185 ± 99 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Description
The AccountListMenu has been been flagged as slow in the past, so I've memoized some selectors and child elements to make the menu render much, much less.
Related issues
Fixes:
Manual testing steps
main
branchENABLE_WHY_DID_YOU_RENDER
flag onAccountListItem
due to 4 props changing (onClick, closeMenu, etc)ENABLE_WHY_DID_YOU_RENDER
flag onAccountListItem
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist