mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Fix infinite re-render when linking to alert redirect page (#84305)
fix: move where the fallback array is initialized so not to create an infinite re-render
This commit is contained in:
parent
d0885ffdaa
commit
9c7a5ed506
@ -67,7 +67,7 @@ export function useCloudCombinedRulesMatching(
|
||||
const { dsFeatures, isLoadingDsFeatures } = useDataSourceFeatures(ruleSourceName);
|
||||
|
||||
const {
|
||||
currentData: promRuleNs = [],
|
||||
currentData,
|
||||
isLoading: isLoadingPromRules,
|
||||
error: promRuleNsError,
|
||||
} = alertRuleApi.endpoints.prometheusRuleNamespaces.useQuery({
|
||||
@ -87,6 +87,7 @@ export function useCloudCombinedRulesMatching(
|
||||
if (promRuleNsError) {
|
||||
throw new Error('Unable to obtain Prometheus rules');
|
||||
}
|
||||
const promRuleNs = currentData || [];
|
||||
|
||||
const rulerGroups: RulerRuleGroupDTO[] = [];
|
||||
if (dsFeatures?.rulerConfig) {
|
||||
@ -114,7 +115,7 @@ export function useCloudCombinedRulesMatching(
|
||||
const rules = namespaces.flatMap((ns) => ns.groups.flatMap((group) => group.rules));
|
||||
|
||||
return rules;
|
||||
}, [dsSettings, dsFeatures, isLoadingPromRules, promRuleNsError, promRuleNs, fetchRulerRuleGroup]);
|
||||
}, [dsSettings, dsFeatures, isLoadingPromRules, promRuleNsError, currentData, fetchRulerRuleGroup]);
|
||||
|
||||
return { loading: isLoadingDsFeatures || loading, error: error, rules: value };
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user