Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix react-hooks/exhaustive-deps error on useCategories.ts #4261

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 0 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -794,8 +794,6 @@ 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/useCategories.ts',
'packages/desktop-client/src/hooks/useProperFocus.tsx',
],

Expand Down
7 changes: 5 additions & 2 deletions packages/desktop-client/src/hooks/useCategories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import { getCategories } from 'loot-core/client/queries/queriesSlice';

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

import { useInitialMount } from './useInitialMount';

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

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

return useSelector(state => state.queries.categories);
}
6 changes: 6 additions & 0 deletions upcoming-release-notes/4261.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 useCategories.ts
Loading