Fix react-hooks/exhaustive-deps in ImportTransactionsModal (#6868)

* Fix react-hooks/exhaustive-deps in ImportTransactionsModal

* [autofix.ci] apply automated fixes

* Add release notes for PR #6868

* Update category to Maintenance and fix warnings

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Joel Jeremy Marquez
2026-02-05 09:09:04 -08:00
committed by GitHub
parent b271de32b6
commit 16ec636358
2 changed files with 11 additions and 28 deletions

View File

@@ -2,6 +2,7 @@
import React, {
useCallback,
useEffect,
useEffectEvent,
useState,
type ComponentProps,
} from 'react';
@@ -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,
@@ -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 },

View File

@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [joel-jeremy]
---
Fix react-hooks/exhaustive-deps in ImportTransactionsModal