From 6809fd44e0e7c5188e788f6830eb42bcb1045d97 Mon Sep 17 00:00:00 2001 From: EnzoVezzaro Date: Mon, 10 Oct 2022 05:52:57 -0400 Subject: [PATCH] set default values in asset stats (#1733) --- .../Asset/AssetActions/AssetStats/index.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/Asset/AssetActions/AssetStats/index.tsx b/src/components/Asset/AssetActions/AssetStats/index.tsx index 0579fcbe0..dd6e79991 100644 --- a/src/components/Asset/AssetActions/AssetStats/index.tsx +++ b/src/components/Asset/AssetActions/AssetStats/index.tsx @@ -1,13 +1,23 @@ import { useAsset } from '@context/Asset' import { useUserPreferences } from '@context/UserPreferences' import { formatPrice } from '@shared/Price/PriceUnit' -import React from 'react' +import React, { useEffect, useState } from 'react' import styles from './index.module.css' export default function AssetStats() { const { locale } = useUserPreferences() const { asset } = useAsset() - const { orders, allocated } = asset.stats + const [orders, setOrders] = useState(0) + const [allocated, setAllocated] = useState(0) + + useEffect(() => { + if (!asset) return + + const { orders, allocated } = asset.stats + + setOrders(orders) + setAllocated(allocated) + }, [asset]) return (