DashboardList: Throttle the re-renders (#99982)

This commit is contained in:
Bogdan Matei
2025-02-04 14:14:28 +02:00
committed by GitHub
parent 5d232daf0b
commit d06d646aa1
@@ -1,6 +1,6 @@
import { take } from 'lodash';
import { useEffect, useMemo, useState } from 'react';
import * as React from 'react';
import { SyntheticEvent, useEffect, useMemo, useState } from 'react';
import { useThrottle } from 'react-use';
import {
DataLinkBuiltInVars,
@@ -107,13 +107,15 @@ export function DashList(props: PanelProps<Options>) {
const dispatch = useDispatch();
const navIndex = useSelector((state) => state.navIndex);
const throttledRenderCount = useThrottle(props.renderCounter, 5000);
useEffect(() => {
fetchDashboards(props.options, props.replaceVariables).then((dashes) => {
setDashboards(dashes);
});
}, [props.options, props.replaceVariables, props.renderCounter]);
}, [props.options, props.replaceVariables, throttledRenderCount]);
const toggleDashboardStar = async (e: React.SyntheticEvent, dash: Dashboard) => {
const toggleDashboardStar = async (e: SyntheticEvent, dash: Dashboard) => {
const { uid, title, url } = dash;
e.preventDefault();
e.stopPropagation();