diff --git a/src/app/search/[id]/_components/order-stock/buy-and-sell/current-price.tsx b/src/app/search/[id]/_components/order-stock/buy-and-sell/current-price.tsx index 6c6f525..cad203d 100644 --- a/src/app/search/[id]/_components/order-stock/buy-and-sell/current-price.tsx +++ b/src/app/search/[id]/_components/order-stock/buy-and-sell/current-price.tsx @@ -8,6 +8,10 @@ import { getKoreanPrice } from "@/utils/price"; export default function CurrentPrice() { const { stockInfo } = useStockInfoContext(); + if (!stockInfo) { + return
주식 정보를 불러오고 있습니다.
; + } + return (
{Array.from({ length: 4 }).map((_, index) => ( diff --git a/src/app/search/[id]/_components/order-stock/buy-and-sell/index.tsx b/src/app/search/[id]/_components/order-stock/buy-and-sell/index.tsx index 7218a37..c299273 100644 --- a/src/app/search/[id]/_components/order-stock/buy-and-sell/index.tsx +++ b/src/app/search/[id]/_components/order-stock/buy-and-sell/index.tsx @@ -81,7 +81,9 @@ export default function BuyAndSell({ setPriceType(newPriceType); setValue( "bidding", - newPriceType === PriceType.Market ? Number(stockInfo.stockPrice) : 0, + newPriceType === PriceType.Market + ? Number(stockInfo?.stockPrice ?? 0) + : 0, ); }; diff --git a/src/app/search/[id]/_components/order-stock/buy-and-sell/input-field.tsx b/src/app/search/[id]/_components/order-stock/buy-and-sell/input-field.tsx index f7d14db..28be46a 100644 --- a/src/app/search/[id]/_components/order-stock/buy-and-sell/input-field.tsx +++ b/src/app/search/[id]/_components/order-stock/buy-and-sell/input-field.tsx @@ -77,7 +77,7 @@ export default function InputField({ number={type === "count" && quantity} state={state ?? ""} setState={(value) => setState(type, value ? Number(value) : 0)} - stockPrice={type === "bidding" && stockInfo.stockPrice} + stockPrice={type === "bidding" ? stockInfo?.stockPrice : undefined} />