Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamic arrray map #415

Open
hmssameer55 opened this issue Jul 10, 2024 · 2 comments
Open

dynamic arrray map #415

hmssameer55 opened this issue Jul 10, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@hmssameer55
Copy link

locales/en.ts

faqs: {
section1: [
{ label: "faq1", value: "faq1" },
{ label: "faq2", value: "faq2" },
],
section2: [{ label: "faq3", value: "faq3" }],
},

//how to map this dynamic data in a component if you can share an example usage it would be very helpful. Thanks in advance

@hmssameer55 hmssameer55 added the enhancement New feature or request label Jul 10, 2024
@SamuelChojnacki
Copy link

same issue

@SamuelChojnacki
Copy link

SamuelChojnacki commented Nov 18, 2024

exemple to resolve this :

`'use client';
import { GitHubLogoIcon, InstagramLogoIcon, LinkedInLogoIcon, TwitterLogoIcon } from '@radix-ui/react-icons';
import { useTranslations } from 'next-intl';

// Type des clés du dictionnaire
type SocialKey = 'linkedin' | 'instagram' | 'twitter' | 'github';

// Composant SocialLinks
const SocialLinks = ({ className }: { className?: string }) => {
const b = useTranslations('social');

// Map des icônes associées à chaque réseau
const icons: Record<SocialKey, JSX.Element> = {
instagram: ,
linkedin: ,
twitter: ,
github :
};

const socialKeys: SocialKey[] = ['linkedin', 'instagram', 'twitter', 'github'];

// Génération des liens
return (


{socialKeys.map((key) => (
<a
key={key}
href={b(${key}.href)}
aria-label={b(${key}.label)}
className="cursor-pointer hover:text-slate-500 dark:hover:text-slate-500"
>
{icons[key]}

))}

);
};

export default SocialLinks;`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants