Skip to content

Commit cacc305

Browse files
committed
Fix undefined symbol
1 parent 9040aeb commit cacc305

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

src/components/CoinCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export const CoinCard = ({ coin }: CoinCardProps) => {
134134
<div
135135
className={`absolute inset-0 flex ${getColorForId(coin.coinId)} text-background justify-center items-center rounded-full`}
136136
>
137-
{displaySymbol.slice(0, 3)}
137+
{displaySymbol?.slice(0, 3)}
138138
</div>
139139

140140
{/* Image (displayed on top if available and loaded successfully) */}

src/components/TokenImage.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { memo, useCallback, useEffect, useState } from "react";
33
import { EthereumIcon } from "./EthereumIcon";
44

55
const getInitials = (symbol: string) => {
6-
return symbol.slice(0, 2).toUpperCase();
6+
return symbol?.slice(0, 2).toUpperCase() ?? "";
77
};
88

99
// Color map for token initials - matching your screenshot
1010
const getColorForSymbol = (symbol: string) => {
11-
const symbolKey = symbol.toLowerCase();
11+
const symbolKey = symbol?.toLowerCase() ?? "";
1212
const colorMap: Record<string, { bg: string; text: string }> = {
1313
eth: { bg: "bg-black", text: "text-white" },
1414
za: { bg: "bg-red-500", text: "text-white" },
@@ -186,7 +186,9 @@ export const TokenImage = memo(
186186
if (cached === "true") {
187187
// We know this token has no URI, use the optimized render path
188188
return (
189-
<div className={`w-8 h-8 flex ${bg} ${text} justify-center items-center rounded-full text-xs font-medium`}>
189+
<div
190+
className={`w-8 h-8 flex ${bg} ${text} justify-center items-center rounded-full text-xs font-medium`}
191+
>
190192
{getInitials(token.symbol)}
191193
</div>
192194
);
@@ -198,7 +200,9 @@ export const TokenImage = memo(
198200
}
199201

200202
return (
201-
<div className={`w-8 h-8 flex ${bg} ${text} justify-center items-center rounded-full text-xs font-medium`}>
203+
<div
204+
className={`w-8 h-8 flex ${bg} ${text} justify-center items-center rounded-full text-xs font-medium`}
205+
>
202206
{getInitials(token.symbol)}
203207
</div>
204208
);
@@ -208,7 +212,9 @@ export const TokenImage = memo(
208212
if (!actualImageUrl && !imageError) {
209213
return (
210214
<div className="relative w-8 h-8 rounded-full overflow-hidden">
211-
<div className={`w-8 h-8 flex ${bg} ${text} justify-center items-center rounded-full`}>
215+
<div
216+
className={`w-8 h-8 flex ${bg} ${text} justify-center items-center rounded-full`}
217+
>
212218
{getInitials(token.symbol)}
213219
</div>
214220
</div>
@@ -243,6 +249,9 @@ export const TokenImage = memo(
243249
},
244250
(prevProps, nextProps) => {
245251
// Only re-render if token ID or URI changes
246-
return prevProps.token.id === nextProps.token.id && prevProps.token.tokenUri === nextProps.token.tokenUri;
252+
return (
253+
prevProps.token.id === nextProps.token.id &&
254+
prevProps.token.tokenUri === nextProps.token.tokenUri
255+
);
247256
},
248257
);

0 commit comments

Comments
 (0)