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,
|
Tooltip,
|
||||||
Title
|
Title
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Use a default export to lazy-load the charting library.
|
||||||
|
export default FeatureMetricsChart;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { FeatureMetricsTable } from '../FeatureMetricsTable/FeatureMetricsTable';
|
import { FeatureMetricsTable } from '../FeatureMetricsTable/FeatureMetricsTable';
|
||||||
import { IFeatureMetricsRaw } from 'interfaces/featureToggle';
|
import { IFeatureMetricsRaw } from 'interfaces/featureToggle';
|
||||||
import { FeatureMetricsStatsRaw } from '../FeatureMetricsStats/FeatureMetricsStatsRaw';
|
import { FeatureMetricsStatsRaw } from '../FeatureMetricsStats/FeatureMetricsStatsRaw';
|
||||||
import { FeatureMetricsChart } from '../FeatureMetricsChart/FeatureMetricsChart';
|
|
||||||
import { Box, Typography } from '@mui/material';
|
import { Box, Typography } from '@mui/material';
|
||||||
import theme from 'themes/theme';
|
import theme from 'themes/theme';
|
||||||
import { useId } from 'hooks/useId';
|
import { useId } from 'hooks/useId';
|
||||||
|
import React, { Suspense } from 'react';
|
||||||
|
|
||||||
interface IFeatureMetricsContentProps {
|
interface IFeatureMetricsContentProps {
|
||||||
metrics: IFeatureMetricsRaw[];
|
metrics: IFeatureMetricsRaw[];
|
||||||
@ -34,14 +34,14 @@ export const FeatureMetricsContent = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<Suspense fallback={null}>
|
||||||
<Box
|
<Box
|
||||||
borderTop={1}
|
borderTop={1}
|
||||||
pt={2}
|
pt={2}
|
||||||
mt={3}
|
mt={3}
|
||||||
borderColor={theme.palette.grey[200]}
|
borderColor={theme.palette.grey[200]}
|
||||||
>
|
>
|
||||||
<FeatureMetricsChart
|
<LazyFeatureMetricsChart
|
||||||
metrics={metrics}
|
metrics={metrics}
|
||||||
hoursBack={hoursBack}
|
hoursBack={hoursBack}
|
||||||
statsSectionId={statsSectionId}
|
statsSectionId={statsSectionId}
|
||||||
@ -61,6 +61,10 @@ export const FeatureMetricsContent = ({
|
|||||||
tableSectionId={tableSectionId}
|
tableSectionId={tableSectionId}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</>
|
</Suspense>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const LazyFeatureMetricsChart = React.lazy(
|
||||||
|
() => import('../FeatureMetricsChart/FeatureMetricsChart')
|
||||||
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user