Skip to content

Commit

Permalink
refactor(cashier onboarding): refactor code (apply memorization)
Browse files Browse the repository at this point in the history
  • Loading branch information
heorhi-deriv committed Aug 22, 2022
1 parent f894fe1 commit d2433e8
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,18 @@ const CashierOnboarding = ({
}) => {
const history = useHistory();
const is_crypto = !!currency && isCryptocurrency(currency);
const has_crypto_account = Object.values(accounts).some(acc_settings => isCryptocurrency(acc_settings.currency));
const has_fiat_account = Object.values(accounts).some(
acc_settings => !acc_settings.is_virtual && !isCryptocurrency(acc_settings.currency)
const has_crypto_account = React.useMemo(
() => Object.values(accounts).some(acc_settings => isCryptocurrency(acc_settings.currency)),
[accounts]
);
const has_fiat_account = React.useMemo(
() =>
Object.values(accounts).some(
acc_settings => !acc_settings.is_virtual && !isCryptocurrency(acc_settings.currency)
),
[accounts]
);

const is_currency_banner_visible =
(!is_crypto && !can_change_fiat_currency) || (is_crypto && available_crypto_currencies.length > 0);

Expand Down

0 comments on commit d2433e8

Please sign in to comment.