fix: default asset selection (#11222)
This commit is contained in:
parent
724f04c423
commit
fdca72830b
@ -66,11 +66,17 @@ function Balances ({ className, infos = [] }: Props): React.ReactElement<Props>
|
||||
);
|
||||
|
||||
useEffect((): void => {
|
||||
setInfo(() =>
|
||||
infoIndex >= 0
|
||||
? completeInfos.find(({ id }) => id.toString() === infoIndex.toString()) ?? null
|
||||
: null
|
||||
);
|
||||
const info = infoIndex >= 0
|
||||
? completeInfos.find(({ id }) => id.toString() === infoIndex.toString()) ?? null
|
||||
: null;
|
||||
|
||||
// if no info found (usually happens on first load), select the first one automatically
|
||||
if (!info) {
|
||||
setInfo(completeInfos.at(0) ?? null);
|
||||
setInfoIndex(completeInfos.at(0)?.id?.toNumber() ?? 0);
|
||||
} else {
|
||||
setInfo(info);
|
||||
}
|
||||
}, [completeInfos, infoIndex]);
|
||||
|
||||
return (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user