-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Performance: find wallets first render optimizations #13139
Conversation
✅ Deploy Preview for ethereumorg ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -47,7 +43,6 @@ export const MobileFiltersMenu = ({ | |||
onClose, | |||
}: MobileFiltersMenuProps) => { | |||
const { t } = useTranslation("page-wallets-find-wallet") | |||
const { filteredWallets } = useWalletTable({ filters, t, walletData }) |
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.
Moved this hook to the parent (page component) to share the results and minimize the calls we do for it since its doing the main filtering.
filteredWallets, | ||
updateMoreInfo, | ||
walletCardData, | ||
} = useWalletTable({ filters, t, walletData }) |
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.
As mentioned before, moved this to the parent.
@@ -232,6 +234,17 @@ const WalletTable = ({ | |||
}) | |||
} | |||
|
|||
const showMoreInfo = (wallet) => { |
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.
Moved this function creation outside of the .map
loop.
@@ -120,20 +120,12 @@ export const useWalletTable = ({ | |||
}, | |||
] | |||
|
|||
const [walletCardData, setWalletData] = useState( | |||
const [walletCardData, setWalletData] = useState(() => |
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.
Use the initialized function to run this map only once.
return { ...wallet, moreInfo: false, key: wallet.name } | ||
}) | ||
) | ||
}, [walletData]) |
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.
Removed since walletData
is not never going to change now that we build the list at build time. This reduces also one extra render that we had.
Lighthouse scores are calculated based on the latest audit results |
}} | ||
/> | ||
{/* Use `Show` instead of `hideBelow` prop to avoid rendering the sidebar on mobile */} | ||
<Show above="lg"> |
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.
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.
Okay.. yeah, if we're preventing a large unnecessary chunk of data from loading then I think it's worth it.
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.
Looks good, nice job @pettinarip!
Description
Refactor the find wallet logic to optimize the first render.
Current dev
Task 1: 550ms
Task 2: 2.2s - 2.7s
Task 3: 1.4s
With optimizations
Task 1: 500ms
Task 2: 1.8s
Task 3: 1.2s