1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

refactor: lazy-load the charting library (#1184)

This commit is contained in:
olav 2022-08-02 10:23:55 +02:00 committed by GitHub
parent 710ebe08b3
commit 0d5f55a706
2 changed files with 11 additions and 4 deletions

View File

@ -67,3 +67,6 @@ ChartJS.register(
Tooltip,
Title
);
// Use a default export to lazy-load the charting library.
export default FeatureMetricsChart;

View File

@ -1,10 +1,10 @@
import { FeatureMetricsTable } from '../FeatureMetricsTable/FeatureMetricsTable';
import { IFeatureMetricsRaw } from 'interfaces/featureToggle';
import { FeatureMetricsStatsRaw } from '../FeatureMetricsStats/FeatureMetricsStatsRaw';
import { FeatureMetricsChart } from '../FeatureMetricsChart/FeatureMetricsChart';
import { Box, Typography } from '@mui/material';
import theme from 'themes/theme';
import { useId } from 'hooks/useId';
import React, { Suspense } from 'react';
interface IFeatureMetricsContentProps {
metrics: IFeatureMetricsRaw[];
@ -34,14 +34,14 @@ export const FeatureMetricsContent = ({
}
return (
<>
<Suspense fallback={null}>
<Box
borderTop={1}
pt={2}
mt={3}
borderColor={theme.palette.grey[200]}
>
<FeatureMetricsChart
<LazyFeatureMetricsChart
metrics={metrics}
hoursBack={hoursBack}
statsSectionId={statsSectionId}
@ -61,6 +61,10 @@ export const FeatureMetricsContent = ({
tableSectionId={tableSectionId}
/>
</Box>
</>
</Suspense>
);
};
const LazyFeatureMetricsChart = React.lazy(
() => import('../FeatureMetricsChart/FeatureMetricsChart')
);