Skip to content

Commit 3716463

Browse files
fix hook issue
1 parent 1608124 commit 3716463

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

plugins/kiali/src/pages/IstioConfigDetails/IstioConfigDetailsPage.tsx

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import * as React from 'react';
22
import AceEditor from 'react-ace';
33
import { useParams } from 'react-router-dom';
4-
import { useAsyncFn, useDebounce } from 'react-use';
54

65
import { Content } from '@backstage/core-components';
76
import { useApi } from '@backstage/core-plugin-api';
87

9-
import { CircularProgress, Grid } from '@material-ui/core';
8+
import { Grid } from '@material-ui/core';
109
import jsYaml from 'js-yaml';
1110

1211
import { BreadcrumbView } from '../../components/BreadcrumbView/BreadcrumbView';
@@ -22,6 +21,8 @@ import 'ace-builds/src-noconflict/mode-yaml';
2221
import 'ace-builds/src-noconflict/theme-eclipse';
2322
import 'ace-builds/src-noconflict/theme-twilight';
2423

24+
import { useCallback, useEffect } from 'react';
25+
2526
import {
2627
AceValidations,
2728
parseKialiValidations,
@@ -34,7 +35,7 @@ export const IstioConfigDetailsPage = (): React.JSX.Element => {
3435
const kialiState = React.useContext(KialiContext) as KialiAppState;
3536
const [istioConfig, setIstioConfig] = React.useState<IstioConfigDetails>();
3637

37-
const fetchIstioConfig = async () => {
38+
const fetchIstioConfig = useCallback(() => {
3839
if (!namespace || !objectType || !object) {
3940
kialiState.alertUtils!.add(
4041
`Could not fetch Istio Config: Empty namespace, object type or object name`,
@@ -47,26 +48,12 @@ export const IstioConfigDetailsPage = (): React.JSX.Element => {
4748
.then((istioConfigResponse: IstioConfigDetails) => {
4849
setIstioConfig(istioConfigResponse);
4950
});
50-
};
51+
}, [kialiClient, kialiState.alertUtils, namespace, objectType, object]);
5152

52-
const [{ loading }, refresh] = useAsyncFn(
53-
async () => {
54-
// Check if the config is loaded
55-
await fetchIstioConfig();
56-
},
57-
[],
58-
{ loading: true },
59-
);
60-
useDebounce(refresh, 10);
61-
62-
React.useEffect(() => {
53+
useEffect(() => {
6354
fetchIstioConfig();
6455
}, [fetchIstioConfig, namespace, objectType, object]);
6556

66-
if (loading) {
67-
return <CircularProgress />;
68-
}
69-
7057
const fetchYaml = () => {
7158
const safeDumpOptions = {
7259
styles: {

0 commit comments

Comments
 (0)