Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import React, {
useCallback,
useEffect,
useEffectEvent,
useState,
type ComponentProps,
} from 'react';
Expand Down Expand Up @@ -718,7 +719,7 @@ export function ImportTransactionsModal({
close();
}

const runImportPreview = useCallback(async () => {
const onImportPreview = useEffectEvent(async () => {
// always start from the original parsed transactions, not the previewed ones to ensure rules run
const transactionPreview = await getImportPreview(
parsedTransactions,
Expand All @@ -732,39 +733,15 @@ export function ImportTransactionsModal({
multiplierAmount,
);
setTransactions(transactionPreview);
}, [
getImportPreview,
parsedTransactions,
filetype,
flipAmount,
fieldMappings,
splitMode,
parseDateFormat,
inOutMode,
outValue,
multiplierAmount,
]);
});

useEffect(() => {
if (parsedTransactions.length === 0 || loadingState === 'parsing') {
return;
}

runImportPreview();
// intentionally exclude runImportPreview from dependencies to avoid infinite rerenders
// oxlint-disable-next-line react/exhaustive-deps
}, [
filetype,
flipAmount,
fieldMappings,
splitMode,
parseDateFormat,
inOutMode,
outValue,
multiplierAmount,
loadingState,
parsedTransactions.length,
]);
onImportPreview();
}, [loadingState, parsedTransactions.length]);

const headers: ComponentProps<typeof TableHeader>['headers'] = [
{ name: t('Date'), width: 200 },
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/6868.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [joel-jeremy]
---

Fix react-hooks/exhaustive-deps in ImportTransactionsModal
Loading