Compare commits
No commits in common. "9ee15160e56350fd9a58a5157041d21fd5bd6ee2" and "46484efdea61196accf4d80435df1a18bc55ecb4" have entirely different histories.
9ee15160e5
...
46484efdea
|
|
@ -490,5 +490,4 @@ const PrometheusChart = ({ metricName }) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default React.memo(PrometheusChart);
|
export default React.memo(PrometheusChart);
|
||||||
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import React, { lazy, Suspense } from "react";
|
import React, { lazy, Suspense } from "react";
|
||||||
|
|
||||||
const PrometheusChart = lazy(() => import('../../Charts/PrometheusChart'));
|
const PrometheusChart = lazy(() => import('../../Charts/PrometheusChart'));
|
||||||
import LazyChartBatchRenderer from "../hooks/LazyChartBatchRender";
|
|
||||||
|
|
||||||
// Функция для генерации названия метрики на основе id
|
// Функция для генерации названия метрики на основе id
|
||||||
const getMetricName = (id) => {
|
const getMetricName = (id) => {
|
||||||
|
|
@ -36,7 +35,6 @@ const tabContent = (data) => {
|
||||||
const content = (
|
const content = (
|
||||||
<div>
|
<div>
|
||||||
<h2>{node.title}</h2>
|
<h2>{node.title}</h2>
|
||||||
<LazyChartBatchRenderer charts={node.items.map((child) => tabContent[child.id].content)} />
|
|
||||||
<p>Контент для {node.title}.</p>
|
<p>Контент для {node.title}.</p>
|
||||||
{childrenContent}
|
{childrenContent}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
|
|
||||||
const LazyChartBatchRenderer = ({ charts, batchSize = 3, delay = 150 }) => {
|
|
||||||
const [visibleCharts, setVisibleCharts] = useState([]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
let index = 0;
|
|
||||||
const timer = setInterval(() => {
|
|
||||||
setVisibleCharts((prev) => [
|
|
||||||
...prev,
|
|
||||||
...charts.slice(index, index + batchSize),
|
|
||||||
]);
|
|
||||||
index += batchSize;
|
|
||||||
if (index >= charts.length) clearInterval(timer);
|
|
||||||
}, delay);
|
|
||||||
|
|
||||||
return () => clearInterval(timer);
|
|
||||||
}, [charts]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{visibleCharts.map((chart, idx) => (
|
|
||||||
<div key={idx}>{chart}</div>
|
|
||||||
))}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default LazyChartBatchRenderer;
|
|
||||||
Loading…
Reference in New Issue