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

[WALL] [Fix] Rostislav / WALL-4135 / Fix wallet name in wallet account switcher looking odd in-between switches #15289

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading