Skip to content

Commit

Permalink
useCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-jeremy committed Feb 28, 2025
1 parent c62c2f2 commit d0e06c3
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ComponentPropsWithoutRef } from 'react';
import { useCallback, type ComponentPropsWithoutRef } from 'react';
import { useTranslation } from 'react-i18next';

import { Button } from '@actual-app/components/button';
Expand Down Expand Up @@ -51,12 +51,11 @@ export function BudgetCell<
const format = useFormat();
const { showUndoNotification } = useUndo();
const [budgetType = 'rollover'] = useSyncedPref('budgetType');
const modalBudgetType = budgetType === 'rollover' ? 'envelope' : 'tracking';

const categoryBudgetMenuModal = `${modalBudgetType}-budget-menu` as const;
const categoryNotes = useNotes(category.id);

const onOpenCategoryBudgetMenu = () => {
const onOpenCategoryBudgetMenu = useCallback(() => {
const modalBudgetType = budgetType === 'rollover' ? 'envelope' : 'tracking';
const categoryBudgetMenuModal = `${modalBudgetType}-budget-menu` as const;
dispatch(
pushModal(categoryBudgetMenuModal, {
categoryId: category.id,
Expand Down Expand Up @@ -105,7 +104,16 @@ export function BudgetCell<
},
}),
);
};
}, [
budgetType,
category.id,
category.name,
categoryNotes,
dispatch,
month,
onBudgetAction,
showUndoNotification,
]);

return (
<CellValue
Expand Down

0 comments on commit d0e06c3

Please sign in to comment.