refactoring-backend #3

Merged
lukas.pupkalipinski merged 403 commits from refactoring-backend into main 2026-05-20 20:23:46 +02:00
2 changed files with 32 additions and 10 deletions
Showing only changes of commit e46062d4cd - Show all commits

View File

@@ -138,7 +138,8 @@ function BarTooltip(props: TooltipContentProps): React.JSX.Element | null {
* @param props - `countries` map and `countryNames` map from the * @param props - `countries` map and `countryNames` map from the
* `/api/dashboard/bans/by-country` response. * `/api/dashboard/bans/by-country` response.
*/ */
export const TopCountriesBarChart = memo(function TopCountriesBarChart({ export const TopCountriesBarChart = memo(
function TopCountriesBarChart({
countries, countries,
countryNames, countryNames,
}: TopCountriesBarChartProps): React.JSX.Element { }: TopCountriesBarChartProps): React.JSX.Element {
@@ -198,4 +199,14 @@ export const TopCountriesBarChart = memo(function TopCountriesBarChart({
</ResponsiveContainer> </ResponsiveContainer>
</div> </div>
); );
}); },
(prev, next) => {
// Custom comparison: if countries and countryNames are deeply equal,
// memo returns true (skip render). This prevents Recharts from
// reprocessing 5000+ data points on parent re-renders.
return (
JSON.stringify(prev.countries) === JSON.stringify(next.countries) &&
JSON.stringify(prev.countryNames) === JSON.stringify(next.countryNames)
);
},
);

View File

@@ -130,7 +130,8 @@ function PieTooltip(props: TooltipContentProps): React.JSX.Element | null {
* @param props - `countries` map and `countryNames` map from the * @param props - `countries` map and `countryNames` map from the
* `/api/dashboard/bans/by-country` response. * `/api/dashboard/bans/by-country` response.
*/ */
export const TopCountriesPieChart = memo(function TopCountriesPieChart({ export const TopCountriesPieChart = memo(
function TopCountriesPieChart({
countries, countries,
countryNames, countryNames,
}: TopCountriesPieChartProps): React.JSX.Element { }: TopCountriesPieChartProps): React.JSX.Element {
@@ -199,4 +200,14 @@ export const TopCountriesPieChart = memo(function TopCountriesPieChart({
</ResponsiveContainer> </ResponsiveContainer>
</div> </div>
); );
}); },
(prev, next) => {
// Custom comparison: if countries and countryNames are deeply equal,
// memo returns true (skip render). This prevents Recharts from
// reprocessing 5000+ data points on parent re-renders.
return (
JSON.stringify(prev.countries) === JSON.stringify(next.countries) &&
JSON.stringify(prev.countryNames) === JSON.stringify(next.countryNames)
);
},
);