Files
livedash-node/components/CountryDisplay.tsx
Kaj Kowalski 8b3846539f refactor: apply React best practices and migrate to ESLint CLI
- 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)
2026-01-20 07:05:27 +01:00

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>;
}