-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
feat: Memoise token balance controler hook #6596
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. |
…taMask/metamask-mobile into feat/808_token_balance_controler_hook
…taMask/metamask-mobile into feat/808_token_balance_controler_hook
…taMask/metamask-mobile into feat/808_token_balance_controler_hook
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.
left some comments
app/components/hooks/useTokenBalancesController/useTokenBalancesController.ts
Outdated
Show resolved
Hide resolved
app/components/hooks/useTokenBalancesController/useTokenBalancesController.ts
Show resolved
Hide resolved
app/components/hooks/useTokenBalancesController/useTokenBalancesController.test.tsx
Outdated
Show resolved
Hide resolved
app/components/hooks/useTokenBalancesController/useTokenBalancesController.test.tsx
Outdated
Show resolved
Hide resolved
app/components/hooks/useTokenBalancesController/useTokenBalancesController.test.tsx
Outdated
Show resolved
Hide resolved
…taMask/metamask-mobile into feat/808_token_balance_controler_hook
update test and snapshots to match BN type stringification
…taMask/metamask-mobile into feat/808_token_balance_controler_hook
…taMask/metamask-mobile into feat/808_token_balance_controler_hook
use multiple tests and init store on beforeAll
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.
LGTM
hey @NicolasMassart ! Great work on getting this done. Can you add recordings of what you tested? |
@cortisiko I added recording and a link to Bitrise QA builds |
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.
This is QA passed! Feel free to merge whenever @NicolasMassart
Kudos, SonarCloud Quality Gate passed! |
Development & PR Process
release-xx
label to identify the PR slated for a upcoming release (will be used in release discussion)needs-dev-review
label when work is completedneeds-qa
label when dev review is completedQA Passed
label when QA has signed offDescription
Create a hook that memoises the state request for token balances from
TokenBalancesController
.This hook uses a deep object equality check to replace the default shallow comparison of
useSelector
.Shallow comparison is not fitting the need for the complex data type we use here and it ends in some unwanted re-rendering or render misses due to data not being properly evaluated.
1. What is the reason for the change?
Need for performance improvement that prevents re-rendering when data hasn't deeply changed.
2. What is the improvement/solution?
isEqual
form Lodash lib onuseSelector
dependencies to trigger a new state retrieval.useSelector
call with this new hook inapp/components/UI/Tokens/index.tsx
{data,loading,retry,error}
return object pattern. Currently only{data}
is implemented as the others require some deep controller changes out of the scope of this PR. This is a first step toward generalised controller hooks.{data,loading,retry,error}
return value type interface created with optional loading, retry and error as they are not yet implemented on controlers. But leads the way for future consistent use.Issue
fixes https://github.com/MetaMask/mobile-planning/issues/808
QA test builds
iOS and Android builds available at https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/d0e62919-1ca8-4518-887c-0cf96b2afea3
Recording
Simulator.Screen.Recording.-.iPhone.12.Pro.-.2023-06-23.at.17.08.56.mov
Checklist