Chore: Update and enforce usage of typed react-redux hooks (#55349)

* Chore: Update and enforce usage of typed react-redux hooks
This commit is contained in:
kay delaney
2022-09-19 10:49:35 +01:00
committed by GitHub
parent a3ff758874
commit 64bbb7a7ce
85 changed files with 207 additions and 247 deletions

View File

@@ -1,10 +1,10 @@
import { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { PluginError } from '@grafana/data';
import { useDispatch, useSelector } from 'app/types';
import { sortPlugins, Sorters } from '../helpers';
import { CatalogPlugin, PluginCatalogStoreState, PluginListDisplayMode } from '../types';
import { CatalogPlugin, PluginListDisplayMode } from '../types';
import { fetchAll, fetchDetails, fetchRemotePlugins, install, uninstall } from './actions';
import { setDisplayMode } from './reducer';
@@ -55,7 +55,7 @@ export const useGetSingle = (id: string): CatalogPlugin | undefined => {
useFetchAll();
useFetchDetails(id);
return useSelector((state: PluginCatalogStoreState) => selectById(state, id));
return useSelector((state) => selectById(state, id));
};
export const useGetErrors = (): PluginError[] => {
@@ -120,7 +120,7 @@ export const useFetchAll = () => {
export const useFetchDetails = (id: string) => {
const dispatch = useDispatch();
const plugin = useSelector((state: PluginCatalogStoreState) => selectById(state, id));
const plugin = useSelector((state) => selectById(state, id));
const isNotFetching = !useSelector(selectIsRequestPending(fetchDetails.typePrefix));
const shouldFetch = isNotFetching && plugin && !plugin.details;