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 = const data =
notEnoughData || isLoading ? placeholderData : aggregateOrProjectData; notEnoughData || isLoading ? placeholderData : aggregateOrProjectData;
return ( const options = useMemo(
<> () => ({
<Chart
type='bar'
data={data}
options={{
responsive: true, responsive: true,
interaction: { interaction: {
mode: 'index', mode: 'index' as const,
intersect: false, intersect: false,
}, },
plugins: { plugins: {
@ -157,17 +153,17 @@ export const CreationArchiveChart: FC<ICreationArchiveChartProps> = ({
}, },
tooltip: { tooltip: {
enabled: false, enabled: false,
position: 'average', position: 'average' as const,
external: createTooltip(setTooltip), external: createTooltip(setTooltip),
}, },
}, },
locale: locationSettings.locale, locale: locationSettings.locale,
scales: { scales: {
x: { x: {
type: 'time', type: 'time' as const,
display: true, display: true,
time: { time: {
unit: 'week', unit: 'week' as const,
tooltipFormat: 'PPP', tooltipFormat: 'PPP',
}, },
grid: { grid: {
@ -175,8 +171,8 @@ export const CreationArchiveChart: FC<ICreationArchiveChartProps> = ({
}, },
}, },
y: { y: {
type: 'linear', type: 'linear' as const,
position: 'left', position: 'left' as const,
beginAtZero: true, beginAtZero: true,
title: { title: {
display: true, display: true,
@ -184,7 +180,16 @@ export const CreationArchiveChart: FC<ICreationArchiveChartProps> = ({
}, },
}, },
}, },
}} }),
[theme, locationSettings, setTooltip],
);
return (
<>
<Chart
type='bar'
data={data}
options={options}
height={100} height={100}
width={250} width={250}
/> />