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:
parent
710ebe08b3
commit
0d5f55a706
@ -67,3 +67,6 @@ ChartJS.register(
|
||||
Tooltip,
|
||||
Title
|
||||
);
|
||||
|
||||
// Use a default export to lazy-load the charting library.
|
||||
export default FeatureMetricsChart;
|
||||
|
@ -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')
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user