Skip to content

Commit

Permalink
[WALL] [Fix] Rostislav / WALL-4135 / Fix wallet name in wallet accoun…
Browse files Browse the repository at this point in the history
…t switcher looking odd in-between switches (deriv-com#15289)

* fix: get rid of intermediate state

* refactor: @wojciech-deriv suggestion
  • Loading branch information
rostislav-deriv authored and vinu-deriv committed May 28, 2024
1 parent 2488593 commit ef395a6
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import { Trans } from 'react-i18next';
import { useActiveWalletAccount } from '@deriv/api-v2';
import { WalletText } from '../Base';
Expand All @@ -8,12 +8,20 @@ import WalletListCardDropdown from '../WalletListCardDropdown/WalletListCardDrop
import './WalletListCardDetails.scss';

const WalletListCardDetails: React.FC = () => {
const { data: activeWallet, isLoading } = useActiveWalletAccount();
const isDemo = activeWallet?.is_virtual;
const { data: activeWallet } = useActiveWalletAccount();
const [isDemo, setIsDemo] = useState<boolean>(activeWallet?.is_virtual ?? false);

useEffect(() => {
// update isDemo only when receiving a new defined is_virtual value
// ignore intermediate undefined state when fetching / loading
if (typeof activeWallet?.is_virtual === 'boolean') {
setIsDemo(activeWallet.is_virtual);
}
}, [activeWallet?.is_virtual]);

return (
<div className='wallets-list-details__container'>
{isDemo && !isLoading ? (
{isDemo ? (
<WalletText>
<Trans defaults='USD Demo Wallet' />
</WalletText>
Expand Down

0 comments on commit ef395a6

Please sign in to comment.