mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	Fix: created vs archived rendering errors; memoize options (#10562)
Fixes the rendering / max update depth exceeded errors we were seeing in the console for this chart by memoizing the options. <img width="1710" height="1420" alt="image" src="https://github.com/user-attachments/assets/9a24d4e5-b563-4a3c-9a76-915e0a5fda24" /> Now the chart doesn't throw any errors anymore.
This commit is contained in:
		
							parent
							
								
									7fb523e348
								
							
						
					
					
						commit
						b071b17dd6
					
				@ -134,15 +134,11 @@ export const CreationArchiveChart: FC<ICreationArchiveChartProps> = ({
 | 
			
		||||
    const data =
 | 
			
		||||
        notEnoughData || isLoading ? placeholderData : aggregateOrProjectData;
 | 
			
		||||
 | 
			
		||||
    return (
 | 
			
		||||
        <>
 | 
			
		||||
            <Chart
 | 
			
		||||
                type='bar'
 | 
			
		||||
                data={data}
 | 
			
		||||
                options={{
 | 
			
		||||
    const options = useMemo(
 | 
			
		||||
        () => ({
 | 
			
		||||
            responsive: true,
 | 
			
		||||
            interaction: {
 | 
			
		||||
                        mode: 'index',
 | 
			
		||||
                mode: 'index' as const,
 | 
			
		||||
                intersect: false,
 | 
			
		||||
            },
 | 
			
		||||
            plugins: {
 | 
			
		||||
@ -157,17 +153,17 @@ export const CreationArchiveChart: FC<ICreationArchiveChartProps> = ({
 | 
			
		||||
                },
 | 
			
		||||
                tooltip: {
 | 
			
		||||
                    enabled: false,
 | 
			
		||||
                            position: 'average',
 | 
			
		||||
                    position: 'average' as const,
 | 
			
		||||
                    external: createTooltip(setTooltip),
 | 
			
		||||
                },
 | 
			
		||||
            },
 | 
			
		||||
            locale: locationSettings.locale,
 | 
			
		||||
            scales: {
 | 
			
		||||
                x: {
 | 
			
		||||
                            type: 'time',
 | 
			
		||||
                    type: 'time' as const,
 | 
			
		||||
                    display: true,
 | 
			
		||||
                    time: {
 | 
			
		||||
                                unit: 'week',
 | 
			
		||||
                        unit: 'week' as const,
 | 
			
		||||
                        tooltipFormat: 'PPP',
 | 
			
		||||
                    },
 | 
			
		||||
                    grid: {
 | 
			
		||||
@ -175,8 +171,8 @@ export const CreationArchiveChart: FC<ICreationArchiveChartProps> = ({
 | 
			
		||||
                    },
 | 
			
		||||
                },
 | 
			
		||||
                y: {
 | 
			
		||||
                            type: 'linear',
 | 
			
		||||
                            position: 'left',
 | 
			
		||||
                    type: 'linear' as const,
 | 
			
		||||
                    position: 'left' as const,
 | 
			
		||||
                    beginAtZero: true,
 | 
			
		||||
                    title: {
 | 
			
		||||
                        display: true,
 | 
			
		||||
@ -184,7 +180,16 @@ export const CreationArchiveChart: FC<ICreationArchiveChartProps> = ({
 | 
			
		||||
                    },
 | 
			
		||||
                },
 | 
			
		||||
            },
 | 
			
		||||
                }}
 | 
			
		||||
        }),
 | 
			
		||||
        [theme, locationSettings, setTooltip],
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    return (
 | 
			
		||||
        <>
 | 
			
		||||
            <Chart
 | 
			
		||||
                type='bar'
 | 
			
		||||
                data={data}
 | 
			
		||||
                options={options}
 | 
			
		||||
                height={100}
 | 
			
		||||
                width={250}
 | 
			
		||||
            />
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user