mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 12:43:09 -05:00
Fix react-hooks/exhaustive-deps error on useCategories.ts (#4261)
* Fix react-hooks/exhaustive-deps error on useCategories.ts * Release notes
This commit is contained in:
committed by
GitHub
parent
f5586501bf
commit
fc78d5b546
@@ -791,7 +791,6 @@ export default [
|
||||
'packages/desktop-client/src/components/sort.tsx',
|
||||
'packages/desktop-client/src/components/spreadsheet/useSheetValue.ts',
|
||||
'packages/desktop-client/src/components/transactions/TransactionList.jsx',
|
||||
'packages/desktop-client/src/hooks/useCategories.ts',
|
||||
],
|
||||
|
||||
rules: {
|
||||
|
||||
@@ -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
upcoming-release-notes/4261.md
Normal file
6
upcoming-release-notes/4261.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Maintenance
|
||||
authors: [joel-jeremy]
|
||||
---
|
||||
|
||||
Fix react-hooks/exhaustive-deps error on useCategories.ts
|
||||
Reference in New Issue
Block a user