Skip to content

Commit f5c7470

Browse files
committed
extract constant
1 parent c74d2d3 commit f5c7470

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

ui/components/app/assets/asset-list/cells/generic-asset-cell-layout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
BlockSize,
77
JustifyContent,
88
} from '../../../../../helpers/constants/design-system';
9+
import { ASSET_CELL_HEIGHT } from '../../constants';
910

1011
type GenericAssetCellLayoutProps = {
1112
onClick?: () => void;
@@ -54,7 +55,7 @@ export default function GenericAssetCellLayout({
5455
paddingRight={4}
5556
width={BlockSize.Full}
5657
style={{
57-
height: 62,
58+
height: ASSET_CELL_HEIGHT,
5859
cursor: onClick ? 'pointer' : 'auto',
5960
backgroundColor:
6061
!disableHover && isHovered

ui/components/app/assets/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ export const ACCOUNT_TYPE_LABELS: Partial<Record<KeyringAccountType, string>> =
99
[BtcAccountType.P2wpkh]: 'Native SegWit',
1010
[BtcAccountType.P2tr]: 'Taproot',
1111
};
12+
13+
export const ASSET_CELL_HEIGHT = 62;

ui/components/app/assets/token-list/token-list.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import React, { useContext, useEffect, useMemo, useRef } from 'react';
1+
import React, { useContext, useEffect, useMemo } from 'react';
22
import { useSelector } from 'react-redux';
33
import { type CaipChainId, type Hex } from '@metamask/utils';
44
import { NON_EVM_TESTNET_IDS } from '@metamask/multichain-network-controller';
55
import { useVirtualizer } from '@tanstack/react-virtual';
66
import TokenCell from '../token-cell';
7+
import { ASSET_CELL_HEIGHT } from '../constants';
78
import {
89
getEnabledNetworksByNamespace,
910
getIsMultichainAccountsState2Enabled,
@@ -150,8 +151,8 @@ function TokenList({ onTokenClick, safeChains }: TokenListProps) {
150151

151152
const virtualizer = useVirtualizer({
152153
count: sortedFilteredTokens.length,
153-
getScrollElement: () => scrollContainerRef.current,
154-
estimateSize: () => 62, // TokenCell height from generic-asset-cell-layout.tsx
154+
getScrollElement: () => scrollContainerRef?.current || null,
155+
estimateSize: () => ASSET_CELL_HEIGHT,
155156
overscan: 5,
156157
});
157158

0 commit comments

Comments
 (0)