mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-02-13 20:15:46 +01:00
- Dynamic import for WordCloud component (code splitting) - Fix waterfall in handleRefresh with Promise.all - Memoize data prep functions in overview page (7 useMemo hooks) - Replace useState+useEffect with useMemo in CountryDisplay/LanguageDisplay - Memoize navigationCards and class getters in dashboard page - Extract inline handlers with useCallback - Fix missing index parameter in TopQuestionsChart map - Migrate from next lint to ESLint CLI (Next.js 16 deprecation)
27 lines
704 B
TypeScript
27 lines
704 B
TypeScript
"use client";
|
|
|
|
import { useMemo } from "react";
|
|
import { getLocalizedCountryName } from "../lib/localization";
|
|
|
|
interface CountryDisplayProps {
|
|
countryCode: string | null | undefined;
|
|
className?: string;
|
|
}
|
|
|
|
/**
|
|
* Component to display a country name from its ISO 3166-1 alpha-2 code
|
|
* Uses Intl.DisplayNames API when available, falls back to the code
|
|
*/
|
|
export default function CountryDisplay({
|
|
countryCode,
|
|
className,
|
|
}: CountryDisplayProps) {
|
|
// Compute directly - Intl.DisplayNames is synchronous
|
|
const countryName = useMemo(
|
|
() => (countryCode ? getLocalizedCountryName(countryCode) : "Unknown"),
|
|
[countryCode]
|
|
);
|
|
|
|
return <span className={className}>{countryName}</span>;
|
|
}
|