diff --git a/src/components/CalculateButton/CalculateButton.tsx b/src/components/CalculateButton/CalculateButton.tsx index 9049f21..2080436 100644 --- a/src/components/CalculateButton/CalculateButton.tsx +++ b/src/components/CalculateButton/CalculateButton.tsx @@ -253,6 +253,7 @@ export function CalculateButton({ setTimeout(() => { inputRef.current?.focus(); }, 0); + getHistory(); }} > diff --git a/src/hooks/useDB.ts b/src/hooks/useDB.ts index 4983f22..e63e7a5 100644 --- a/src/hooks/useDB.ts +++ b/src/hooks/useDB.ts @@ -386,6 +386,7 @@ export function useDB() { return { filteredIncomes, filteredExpenses }; } + function renameBudget(event: React.ChangeEvent) { if (budget && event.target.value) { const newState = produce((draft) => { @@ -395,18 +396,21 @@ export function useDB() { } } - async function getCalcHist(id: string): Promise { - let item; - await calcHistDB - .getItem(id) - .then((i) => { - item = i; - }) - .catch((e: unknown) => { - throw e; - }); - return item ?? []; - } + const getCalcHist = useCallback( + async (id: string): Promise => { + let item; + await calcHistDB + .getItem(id) + .then((i) => { + item = i; + }) + .catch((e: unknown) => { + throw e; + }); + return item ?? []; + }, + [], + ); async function saveCalcHist(id: string, item: CalculationHistoryItem) { const calcHist = await getCalcHist(id);