Fix: Handle undefined budget data
The `useBudgetTabContent` hook was throwing an error when `data` prop was undefined. This commit adds a check to ensure that `data` is defined before accessing its properties.
This commit is contained in:
@@ -13,7 +13,7 @@ interface BudgetData {
|
||||
remainingAmount: number;
|
||||
}
|
||||
|
||||
interface BudgetTabContentProps {
|
||||
export interface BudgetTabContentProps {
|
||||
data: BudgetData;
|
||||
formatCurrency: (amount: number) => string;
|
||||
calculatePercentage: (spent: number, target: number) => number;
|
||||
@@ -26,6 +26,12 @@ const BudgetTabContent: React.FC<BudgetTabContentProps> = ({
|
||||
calculatePercentage,
|
||||
onSaveBudget
|
||||
}) => {
|
||||
// 데이터 유효성 체크 - 데이터가 없으면 기본값 사용
|
||||
if (!data) {
|
||||
console.warn('BudgetTabContent: data prop이 제공되지 않았습니다. 기본값을 사용합니다.');
|
||||
data = { targetAmount: 0, spentAmount: 0, remainingAmount: 0 };
|
||||
}
|
||||
|
||||
const {
|
||||
categoryBudgets,
|
||||
showBudgetInput,
|
||||
|
||||
Reference in New Issue
Block a user