@@ -238,7 +238,28 @@ const TokenBalanceView = ({
238238 ) ;
239239} ;
240240
241- export const TokenSelectorItem : React . FC < TokenSelectorItemProps > = ( {
241+ const formatTokenBalance = ( balance : string ) : string => {
242+ const numericBalance = Number ( balance ) ;
243+ if ( numericBalance === 0 ) {
244+ return '0' ;
245+ }
246+ if ( numericBalance < 0.00001 ) {
247+ return '< 0.00001' ;
248+ }
249+ return parseAmount ( balance , 5 ) || balance ;
250+ } ;
251+
252+ const TOP_ROW_BALANCE_TEXT_STYLE = {
253+ textVariant : TextVariant . BodyMDMedium ,
254+ textColor : TextColor . Default ,
255+ } as const ;
256+
257+ const BOTTOM_ROW_BALANCE_TEXT_STYLE = {
258+ textVariant : TextVariant . BodyMD ,
259+ textColor : TextColor . Alternative ,
260+ } as const ;
261+
262+ const TokenSelectorItemInner : React . FC < TokenSelectorItemProps > = ( {
242263 token,
243264 onPress,
244265 networkName,
@@ -261,17 +282,6 @@ export const TokenSelectorItem: React.FC<TokenSelectorItemProps> = ({
261282
262283 const fiatValue = token . balanceFiat ;
263284
264- const formatTokenBalance = ( balance : string ) : string => {
265- const numericBalance = Number ( balance ) ;
266- if ( numericBalance === 0 ) {
267- return '0' ;
268- }
269- if ( numericBalance < 0.00001 ) {
270- return '< 0.00001' ;
271- }
272- return parseAmount ( balance , 5 ) || balance ;
273- } ;
274-
275285 const selectedVariant =
276286 variant ??
277287 TOKEN_SELECTOR_BALANCE_LAYOUT_VARIANTS [
@@ -288,26 +298,18 @@ export const TokenSelectorItem: React.FC<TokenSelectorItemProps> = ({
288298
289299 const isNative = token . address === ethers . constants . AddressZero ;
290300
291- // to check if the token is a stock by checking if the name includes 'ondo' or 'stock'
292301 const { isStockToken } = useRWAToken ( ) ;
293302
294303 const fiatBalance = shouldShowBalance ? fiatValue : undefined ;
295304 const tokenBalance = shouldShowBalance ? cryptoBalance : undefined ;
296- const topRowBalanceTextStyle = {
297- textVariant : TextVariant . BodyMDMedium ,
298- textColor : TextColor . Default ,
299- } ;
300- const bottomRowBalanceTextStyle = {
301- textVariant : TextVariant . BodyMD ,
302- textColor : TextColor . Alternative ,
303- } ;
304305
305306 const label = token . accountType
306307 ? ACCOUNT_TYPE_LABELS [ token . accountType ]
307308 : undefined ;
308309
309310 return (
310311 < Box
312+ accessible = { false }
311313 flexDirection = { FlexDirection . Row }
312314 alignItems = { AlignItems . center }
313315 style = { styles . container }
@@ -324,11 +326,11 @@ export const TokenSelectorItem: React.FC<TokenSelectorItemProps> = ({
324326 ) }
325327 >
326328 < Box
329+ accessible = { false }
327330 flexDirection = { FlexDirection . Row }
328331 alignItems = { AlignItems . center }
329332 gap = { 4 }
330333 >
331- { /* Token Icon */ }
332334 < BadgeWrapper
333335 style = { styles . badgeWrapper }
334336 badgePosition = { BadgePosition . BottomRight }
@@ -352,19 +354,20 @@ export const TokenSelectorItem: React.FC<TokenSelectorItemProps> = ({
352354 />
353355 </ BadgeWrapper >
354356
355- { /* Token symbol/name on the left, balances on the right (extension layout pattern) */ }
356357 < Box
358+ accessible = { false }
357359 style = { styles . tokenInfo }
358360 flexDirection = { FlexDirection . Column }
359361 gap = { 4 }
360362 >
361363 < Box
364+ accessible = { false }
362365 flexDirection = { FlexDirection . Row }
363366 alignItems = { AlignItems . center }
364367 justifyContent = { JustifyContent . spaceBetween }
365368 >
366- < Box style = { styles . tokenMainInfo } gap = { 4 } >
367- < Box style = { styles . tokenSymbolRow } >
369+ < Box accessible = { false } style = { styles . tokenMainInfo } gap = { 4 } >
370+ < Box accessible = { false } style = { styles . tokenSymbolRow } >
368371 < Text
369372 variant = { TextVariant . BodyMDMedium }
370373 numberOfLines = { 1 }
@@ -401,19 +404,20 @@ export const TokenSelectorItem: React.FC<TokenSelectorItemProps> = ({
401404 balance = { tokenBalance }
402405 isSelected = { isSelected }
403406 textStyle = { styles . rightValue }
404- { ...topRowBalanceTextStyle }
407+ { ...TOP_ROW_BALANCE_TEXT_STYLE }
405408 />
406409 ) : (
407410 < FiatBalanceView
408411 balance = { fiatBalance }
409412 isSelected = { isSelected }
410413 textStyle = { styles . rightValue }
411- { ...topRowBalanceTextStyle }
414+ { ...TOP_ROW_BALANCE_TEXT_STYLE }
412415 />
413416 ) }
414417 </ Box >
415418
416419 < Box
420+ accessible = { false }
417421 flexDirection = { FlexDirection . Row }
418422 alignItems = { AlignItems . center }
419423 justifyContent = { JustifyContent . spaceBetween }
@@ -433,14 +437,14 @@ export const TokenSelectorItem: React.FC<TokenSelectorItemProps> = ({
433437 balance = { fiatBalance }
434438 isSelected = { isSelected }
435439 textStyle = { styles . rightValue }
436- { ...bottomRowBalanceTextStyle }
440+ { ...BOTTOM_ROW_BALANCE_TEXT_STYLE }
437441 />
438442 ) : (
439443 < TokenBalanceView
440444 balance = { tokenBalance }
441445 isSelected = { isSelected }
442446 textStyle = { styles . rightValue }
443- { ...bottomRowBalanceTextStyle }
447+ { ...BOTTOM_ROW_BALANCE_TEXT_STYLE }
444448 />
445449 ) }
446450 </ Box >
@@ -453,3 +457,17 @@ export const TokenSelectorItem: React.FC<TokenSelectorItemProps> = ({
453457 </ Box >
454458 ) ;
455459} ;
460+
461+ export const TokenSelectorItem = React . memo (
462+ TokenSelectorItemInner ,
463+ ( prev , next ) =>
464+ prev . onPress === next . onPress &&
465+ prev . token . address === next . token . address &&
466+ prev . token . chainId === next . token . chainId &&
467+ prev . token . balance === next . token . balance &&
468+ prev . token . balanceFiat === next . token . balanceFiat &&
469+ prev . isSelected === next . isSelected &&
470+ prev . isNoFeeAsset === next . isNoFeeAsset &&
471+ prev . shouldShowBalance === next . shouldShowBalance &&
472+ prev . networkName === next . networkName ,
473+ ) ;
0 commit comments