Skip to content

Convert useSwapsEthToken hook to a selector#10568

Merged
danjm merged 2 commits intodevelopfrom
useSwapsEthToken-to-selector
Mar 4, 2021
Merged

Convert useSwapsEthToken hook to a selector#10568
danjm merged 2 commits intodevelopfrom
useSwapsEthToken-to-selector

Conversation

@danjm
Copy link
Copy Markdown
Contributor

@danjm danjm commented Mar 3, 2021

The useSwapsEthToken does not need to be a hook, as it does not rely on other hooks (with the exception of useSelector, the need for which can just be met with a selector). It can be simplified to being a selector. This will also make it easier to use in more contexts (as it won't need to follow the rules of hooks)

@danjm danjm requested a review from a team as a code owner March 3, 2021 10:38
@danjm danjm requested a review from ryanml March 3, 2021 10:38
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 3, 2021

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.

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [b549c27]
Page Load Metrics (590 ± 31 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint47745874
domContentLoaded3827045896531
load3837055906531
domInteractive3827035896531

Copy link
Copy Markdown
Contributor

@brad-decker brad-decker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the hook file still being used after this? it doesn't appear to be removed in this PR.

checksumAddress,
getAccountByAddress,
} from '../helpers/utils/util';
import {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review note: this is just the code from the hook, now as a selector, it doesn't appear to be modified except in name, and that it is now a selector that expects state as an argument.

* in regular ERC-20 token objects, per the above description.
*
* @returns {SwapsEthToken} The token object representation of the currently
* selected account's ETH balance, as expected by the Swaps API.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doc block now should probably have a @param given it expects state.

ryanml
ryanml previously approved these changes Mar 3, 2021
Copy link
Copy Markdown
Contributor

@ryanml ryanml left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

@danjm
Copy link
Copy Markdown
Contributor Author

danjm commented Mar 3, 2021

@brad-decker your comments are addressed in the latest commit

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [e9dd87a]
Page Load Metrics (609 ± 41 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint448160105
domContentLoaded3787166078641
load3797176098641
domInteractive3787166078641

@danjm danjm merged commit b441dce into develop Mar 4, 2021
@danjm danjm deleted the useSwapsEthToken-to-selector branch March 4, 2021 17:16
@github-actions github-actions bot locked and limited conversation to collaborators Mar 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants