Skip to content
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

perf: Use callback for handlers #10116

Closed
wants to merge 23 commits into from

Conversation

memoyil
Copy link
Collaborator

@memoyil memoyil commented Jun 29, 2024


PR-Codex overview

This PR updates various components and hooks to use useCallback and useMemo for performance optimization.

Detailed summary

  • Updated functions to use useCallback and useMemo for better performance.
  • Replaced inline functions with memoized callbacks in multiple components.
  • Improved efficiency by optimizing function calls in different parts of the codebase.

The following files were skipped due to too many changes: packages/uikit/src/components/MultiSelect/MultiSelect.tsx, apps/web/src/views/Predictions/components/Notification/PauseNotification.tsx, apps/games/components/Footer.tsx, apps/web/src/views/Swap/MMLinkPools/components/MMCommitButton.tsx, apps/web/src/views/Swap/hooks/useWarningImport.tsx, apps/web/src/views/Predictions/components/Notification/ErrorNotification.tsx, apps/web/src/views/Farms/components/FarmTable/Actions/StakedAction.tsx, apps/web/src/components/AddressInputSelect/index.tsx, apps/web/src/views/TradingCompetition/components/RegisterModal/ReactivateProfile.tsx, apps/web/src/components/Menu/UserMenu/WalletTransactions.tsx, apps/web/src/views/Pottery/index.tsx, apps/web/src/views/Nft/market/Collection/Traits/PancakeBunniesTraits.tsx, apps/web/src/views/PancakeSquad/components/Modals/Confirm/index.tsx, apps/web/src/views/Predictions/components/ChainlinkChartDisclaimer.tsx, apps/web/src/views/Home/components/UserBanner/UserDetail.tsx, apps/web/src/components/CrossChainVeCakeModal/components/SwitchToBnbCahinModal.tsx, apps/web/src/components/TransactionDetailModal/index.tsx, apps/web/src/views/Voting/CreateProposal/Choices.tsx, apps/web/src/views/Farms/components/FarmCard/StakeAction.tsx, apps/web/src/views/Ifos/components/IfoVesting/VestingPeriod/TokenInfo.tsx, apps/web/src/views/TradingCompetition/components/RegisterModal/MakeProfile.tsx, apps/web/src/views/TradingCompetition/useRegistrationClaimStatus.ts, apps/web/src/views/LimitOrders/components/CurrencyInputHeader.tsx, apps/web/src/views/Ifos/components/Hero.tsx, apps/aptos/components/Menu/Menu.tsx, packages/uikit/src/components/ThemeSwitcher/ThemeSwitcher.tsx, apps/web/src/views/Ifos/components/IfoVesting/VestingPeriod/Expand.tsx, apps/web/src/views/Nft/market/Collection/Items/ClearAllButton.tsx, apps/web/src/views/Migration/components/v3/OldFarmRow.tsx, packages/uikit/src/hooks/useDialog/DialogContext.tsx, apps/web/src/views/FarmAuction/hooks/useReclaimAuctionBid.ts, apps/web/src/views/GaugesVoting/components/Table/VoteTable/List.tsx, apps/web/src/views/Voting/Proposal/Votes.tsx, apps/web/src/views/Nft/market/ActivityHistory/ClearAllButton.tsx, apps/web/src/views/Predictions/components/RoundCard/CanceledRoundCard.tsx, apps/web/src/views/LimitOrders/components/LimitOrderPrice.tsx, apps/web/src/views/Predictions/components/History/RoundsTab.tsx, apps/web/src/components/CrossChainVeCakeModal/components/NextButton.tsx, apps/web/src/views/Predictions/Leaderboard/components/WalletStatsModal.tsx, apps/aptos/components/WrongNetworkModal.tsx, apps/web/src/views/AffiliatesProgram/components/Dashboard/LoginButton.tsx, apps/web/src/views/TradingReward/components/YourTradingReward/VeCake/VeCakePreview.tsx, apps/web/src/views/LimitOrders/components/ConfirmLimitOrderModal.tsx, apps/web/src/components/PhishingWarningBanner/index.tsx, apps/web/src/views/Predictions/components/RoundCard/SetPositionCard.tsx, apps/web/src/views/AffiliatesProgram/components/OnBoardingModal/index.tsx, apps/web/src/views/Voting/Proposal/Vote.tsx, apps/web/src/views/TradingCompetition/components/ShareImageModal.tsx, packages/uikit/src/components/TokenLogo/TokenLogo.tsx, apps/web/src/views/Predictions/Leaderboard/components/Results/index.tsx, apps/web/src/views/Predictions/components/v1/NothingToClaimModal.tsx, packages/uikit/src/widgets/Modal/BottomDrawer/BottomDrawer.tsx, packages/uikit/src/components/Acknowledgement/index.tsx, apps/web/src/components/GlobalCheckClaimStatus/AnniversaryAchievementModal.tsx, apps/web/src/views/Pottery/components/WinRateModal/index.tsx, apps/web/src/components/ConnectWalletButton.tsx, apps/web/src/components/CrossChainVeCakeModal/components/SyncButton.tsx, packages/uikit/src/widgets/Modal/ModalV2.tsx, apps/web/src/components/ImportTokenWarningModal.tsx, apps/web/src/views/Farms/components/FarmCard/V3/SingleFarmV3Card.tsx, apps/web/src/hooks/useCakeApprove.tsx, apps/web/src/views/Predictions/components/CollectWinningsPopup.tsx, packages/uikit/src/widgets/Modal/Modal.tsx, apps/web/src/views/TradingReward/components/YourTradingReward/VeCake/VeCakeAddCakeOrWeeksModal.tsx, apps/web/src/views/Migration/components/bCake/PMRow.tsx, apps/web/src/views/GaugesVoting/components/GaugesFilter/FilterFieldByType.tsx, apps/web/src/components/ClaimNftModal/ClaimNftModal.tsx, packages/uikit/src/components/CoinSwitcher/CoinSwitcher.tsx, apps/web/src/views/Predictions/components/RoundCard/AIPredictions/AISetPositionCard.tsx, apps/web/src/views/TradingReward/components/YourTradingReward/VeCake/VeCakePreviewTextInfo.tsx, apps/web/src/views/Predictions/components/v1/V1ClaimCheck.tsx, apps/web/src/views/Nft/market/components/BuySellModals/BuyModal/index.tsx, apps/web/src/views/Predictions/components/History/HistoricalBet.tsx, apps/web/src/views/Farms/components/YieldBooster/components/BCakeCalculator.tsx, apps/web/src/views/Predictions/components/PrevNextNav.tsx, apps/web/src/views/Profile/components/EditProfileModal/PauseProfileView.tsx, apps/web/src/views/FixedStaking/components/RestakeFixedStakingModal.tsx, apps/web/src/views/TradingCompetition/components/RegisterModal/RegisterWithProfile.tsx, apps/web/src/views/GaugesVoting/components/Table/GaugesTable/TableHeader.tsx, apps/web/src/views/Migration/bCake.tsx, apps/web/src/views/Ifos/components/IfoFoldableCard/IfoPoolCard/ClaimButton.tsx, apps/web/src/views/Profile/components/EditProfileModal/ApproveCakeView.tsx, apps/web/src/views/Nft/market/ActivityHistory/ActivityFilter.tsx, apps/web/src/views/PancakeSquad/components/Buttons/BuyTickets.tsx, apps/web/src/views/Ifos/components/IfoFoldableCard/index.tsx, apps/web/src/views/Predictions/components/History/BetResult.tsx, apps/aptos/components/Farms/components/FarmCard/HarvestAction.tsx, apps/web/src/views/TradingCompetition/components/ClaimModal/index.tsx, apps/web/src/views/Predictions/components/History/AIPredictions/AIBetResult.tsx, apps/web/src/views/Pottery/components/Pot/Deposit/DepositAction.tsx, apps/web/src/views/Farms/components/BCakeMigrateModal.tsx, apps/web/src/views/Predictions/components/History/Header.tsx, apps/web/src/views/Pools/components/PoolsTable/ActionPanel/Stake.tsx, apps/web/src/views/Profile/components/Achievements/AchievementRow/index.tsx, apps/web/src/components/AccessRisk/index.tsx, apps/web/src/views/AffiliatesProgram/components/Dashboard/MyReferralLink.tsx, apps/web/src/views/Farms/components/YieldBooster/components/bCakeV3/BCakeBoosterCard.tsx, apps/web/src/views/Predictions/components/ReclaimPositionButton.tsx, apps/web/src/views/Predictions/components/CollectRoundWinningsModal.tsx, apps/web/src/views/Swap/MMLinkPools/hooks/useApprove.ts, apps/web/src/views/Predictions/components/TokenSelector/index.tsx, apps/web/src/views/Migration/v3.tsx, apps/web/src/components/CrossChainVeCakeModal/index.tsx, apps/web/src/views/Farms/components/UpdatePositionsReminder.tsx, apps/web/src/views/Farms/components/MultiChainHarvestModal.tsx, apps/web/src/views/CakeStaking/index.tsx, apps/web/src/views/PancakeSquad/components/Buttons/Mint.tsx, apps/web/src/views/Predictions/Desktop.tsx, apps/web/src/views/Migration/components/v3/Step2.tsx, apps/web/src/views/Nft/market/components/Filters/MinMaxFilter/index.tsx, apps/web/src/views/Farms/components/FarmCard/HarvestAction.tsx, apps/web/src/views/ProfileCreation/ProfilePicture.tsx, apps/web/src/views/Predictions/Leaderboard/components/Filters/index.tsx, packages/uikit/src/components/SubMenuItems/SubMenuItems.tsx, apps/web/src/components/Menu/UserMenu/WalletInfo.tsx, apps/aptos/hooks/useAuth.ts, apps/web/src/views/ProfileCreation/UserName.tsx, packages/uikit/src/components/RoiCalculatorModal/RoiCard.tsx, apps/web/src/views/Swap/components/AdvancedSwapDetails.tsx, apps/web/src/views/Nft/market/components/BuySellModals/SellModal/index.tsx, apps/web/src/views/Pottery/components/WinRateModal/WinRateCard.tsx, packages/uikit/src/widgets/Menu/components/UserMenu/index.tsx, apps/web/src/views/Nft/market/Collection/IndividualNFTPage/shared/MoreFromThisCollection.tsx, packages/uikit/src/hooks/useDialog/Dialog.tsx, apps/web/src/views/Predictions/components/RoundCard/OpenRoundCard.tsx, apps/web/src/views/Voting/components/CastVoteModal/index.tsx, apps/web/src/views/Nft/market/components/Filters/ListTraitFilter/index.tsx, apps/web/src/views/Predictions/components/RoundCard/AIPredictions/AIOpenRoundCard.tsx, apps/web/src/views/Nft/market/components/Filters/ListCollectionFilter/index.tsx, apps/web/src/views/Farms/components/FarmTable/Actions/HarvestAction.tsx, packages/uikit/src/components/RoiCalculatorModal/useRoiCalculatorReducer.ts, apps/web/src/components/GlobalCheckClaimStatus/V3AirdropModal.tsx, apps/web/src/views/Pottery/hooks/useWinRateCalculator.tsx, apps/web/src/views/Pools/components/CakeVaultCard/VaultStakeModal.tsx, apps/web/src/views/Lottery/components/ClaimPrizesModal/ClaimPrizesInner.tsx, apps/web/src/views/Lottery/components/BuyTicketsModal/TicketInput.tsx

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

vercel bot commented Jun 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
aptos-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 24, 2024 5:55pm
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
blog ⬜️ Ignored (Inspect) Visit Preview Jul 24, 2024 5:55pm
bridge ⬜️ Ignored (Inspect) Visit Preview Jul 24, 2024 5:55pm
games ⬜️ Ignored (Inspect) Visit Preview Jul 24, 2024 5:55pm
gamification ⬜️ Ignored (Inspect) Visit Preview Jul 24, 2024 5:55pm
uikit ⬜️ Ignored (Inspect) Visit Preview Jul 24, 2024 5:55pm
web ⬜️ Ignored (Inspect) Visit Preview Jul 24, 2024 5:55pm

Copy link

changeset-bot bot commented Jun 29, 2024

⚠️ No Changeset found

Latest commit: ec39f91

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@memoyil memoyil marked this pull request as draft June 29, 2024 10:59
@memoyil memoyil force-pushed the feature/perf_use_callback_for_handlers branch from 85f50bd to 29db6fb Compare June 29, 2024 11:01
@memoyil memoyil force-pushed the feature/perf_use_callback_for_handlers branch from 29db6fb to 2822d2a Compare June 29, 2024 11:04
@memoyil memoyil force-pushed the feature/perf_use_callback_for_handlers branch from 2822d2a to 7321a7d Compare June 29, 2024 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants