1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-01 13:47:27 +02: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:
Thomas Heartman 2025-08-28 14:48:53 +02:00 committed by GitHub
parent 7fb523e348
commit b071b17dd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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}
/>