mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user