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

Chakra v3 | EP 103 | PlatformIconList.tsx=> as={iconMap[platform.slug] #16

Open
MajidRB opened this issue Nov 18, 2024 · 0 comments
Open

Comments

@MajidRB
Copy link

MajidRB commented Nov 18, 2024

React.Children.only expected to receive a single React element child.
The above error occurred in the <Styled(svg)> component:

in this peace of code:

{platforms.map((platform) => (
          <Icon
            key={platform.id}
            as={iconMap[platform.slug]}
            color="gray.500"
          /> )}

i encountered those errors. so i tried so many different ways to debugging.
even AI couldn't help me at first!!

two days i spent time on this! at last i was certain the problem was in this part:
as={iconMap[platform.slug]}

with help of AI (GPT)
i could figure this out:

{platforms.map((platform) => (
          <Icon key={platform.id}>
            {iconMap[platform.slug] ? (
              React.createElement(iconMap[platform.slug])
            ) : (
              <BsGlobe />
            )}
          </Icon>
        ))}
@MajidRB MajidRB changed the title Chakra v3 | EP 103 | PlatformList.tsx=> as={iconMap[platform.slug] Chakra v3 | EP 103 | PlatformIconList.tsx=> as={iconMap[platform.slug] Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant