Skip to content

Commit 5ca1298

Browse files
committed
fix: properly handle stringifying values
1 parent 8a21b2a commit 5ca1298

File tree

1 file changed

+12
-5
lines changed
  • apps/insights/src/components/LivePrices

1 file changed

+12
-5
lines changed

apps/insights/src/components/LivePrices/index.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,18 @@ export const LiveValue = <T extends keyof PriceData>({
178178
}: LiveValueProps<T>) => {
179179
const { current } = useLivePriceData(cluster, feedKey);
180180

181-
return current !== undefined || defaultValue !== undefined ? (
182-
(current?.[field]?.toString() ?? defaultValue)
183-
) : (
184-
<Skeleton width={SKELETON_WIDTH} />
185-
);
181+
if (current !== undefined || defaultValue !== undefined) {
182+
const value = current?.[field];
183+
if (typeof value === "string") {
184+
return value;
185+
} else if (typeof value === "number" || typeof value === "bigint") {
186+
return value.toString();
187+
} else {
188+
return value ? JSON.stringify(value) : defaultValue;
189+
}
190+
} else {
191+
return <Skeleton width={SKELETON_WIDTH} />;
192+
}
186193
};
187194

188195
type LiveComponentValueProps<T extends keyof PriceComponent["latest"]> = {

0 commit comments

Comments
 (0)