Skip to content

Commit 169b339

Browse files
committed
Fix AssetValue historic rate default rendering
1 parent 6141bb0 commit 169b339

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

ui/shared/value/AssetValue.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,14 @@ const AssetValue = ({
4545
const hasCurrent = Boolean(exchangeRate);
4646
const hasToggle = hasHistoric && hasCurrent && hasExchangeRateToggle && amount !== '0';
4747

48-
const [ showHistoric, setShowHistoric ] = React.useState(hasHistoric);
49-
50-
React.useEffect(() => {
51-
setShowHistoric(hasHistoric);
52-
}, [ hasHistoric ]);
48+
const [ showHistoricOverride, setShowHistoricOverride ] = React.useState<boolean | undefined>(undefined);
49+
const showHistoric = hasHistoric && (showHistoricOverride ?? true);
5350

5451
const activeExchangeRate = showHistoric ? historicExchangeRate : exchangeRate;
5552

5653
const handleToggle = React.useCallback(() => {
5754
if (hasToggle) {
58-
setShowHistoric(prev => !prev);
55+
setShowHistoricOverride(prev => (prev === undefined ? false : !prev));
5956
}
6057
}, [ hasToggle ]);
6158

0 commit comments

Comments
 (0)