Skip to content
Snippets Groups Projects
useCategories.ts 544 B
Newer Older
  • Learn to ignore specific revisions
  • import { useEffect } from 'react';
    
    import { useDispatch, useSelector } from 'react-redux';
    
    import { getCategories } from 'loot-core/src/client/actions';
    import { type State } from 'loot-core/src/client/state-types';
    
      const dispatch = useDispatch();
      const categoriesLoaded = useSelector(
        (state: State) => state.queries.categoriesLoaded,
    
        if (!categoriesLoaded) {
          dispatch(getCategories());
    
      return useSelector(state => state.queries.categories);