Skip to content

Commit

Permalink
Fix react-hooks/exhaustive-deps error on useAccounts.ts (#4262)
Browse files Browse the repository at this point in the history
* Fix react-hooks/exhaustive-deps error on useAccounts.ts

* Release notes
  • Loading branch information
joel-jeremy authored Feb 19, 2025
1 parent aea6e79 commit 10c35e1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ export default [
'packages/desktop-client/src/components/transactions/TransactionList.jsx',
'packages/desktop-client/src/components/transactions/TransactionsTable.jsx',
'packages/desktop-client/src/components/transactions/TransactionsTable.test.jsx',
'packages/desktop-client/src/hooks/useAccounts.ts',
// 'packages/desktop-client/src/hooks/useAccounts.ts',
'packages/desktop-client/src/hooks/useCategories.ts',
'packages/desktop-client/src/hooks/useProperFocus.tsx',
],
Expand Down
7 changes: 5 additions & 2 deletions packages/desktop-client/src/hooks/useAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import { getAccounts } from 'loot-core/client/queries/queriesSlice';

import { useSelector, useDispatch } from '../redux';

import { useInitialMount } from './useInitialMount';

export function useAccounts() {
const dispatch = useDispatch();
const accountsLoaded = useSelector(state => state.queries.accountsLoaded);
const isInitialMount = useInitialMount();

useEffect(() => {
if (!accountsLoaded) {
if (isInitialMount && !accountsLoaded) {
dispatch(getAccounts());
}
}, []);
}, [accountsLoaded, dispatch, isInitialMount]);

return useSelector(state => state.queries.accounts);
}
6 changes: 6 additions & 0 deletions upcoming-release-notes/4262.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 error on useAccounts.ts

0 comments on commit 10c35e1

Please sign in to comment.