mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-09 03:32:54 -05:00
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:
committed by
GitHub
parent
b271de32b6
commit
16ec636358
@@ -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 },
|
||||
|
||||
6
upcoming-release-notes/6868.md
Normal file
6
upcoming-release-notes/6868.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Maintenance
|
||||
authors: [joel-jeremy]
|
||||
---
|
||||
|
||||
Fix react-hooks/exhaustive-deps in ImportTransactionsModal
|
||||
Reference in New Issue
Block a user