Here is the error:
Uncaught Error: React.Children.only expected to receive a single React element child. at Object.onlyChild [as only]
And here is my code:
import {
FaWindows,
FaPlaystation,
FaXbox,
FaApple,
FaLinux,
FaAndroid,
} from "react-icons/fa";
import { MdPhoneIphone } from "react-icons/md";
import { SiNintendo } from "react-icons/si";
import { BsGlobe } from "react-icons/bs";
import { Platform } from "@/hooks/useGames";
import { HStack, Icon, Text } from "@chakra-ui/react";
import { IconType } from "react-icons";
interface Props {
platforms: Platform[];
}
// TODO: Figure out why Icons is not being mapped.
const PlatformIconList = ({ platforms }: Props) => {
const iconMap: { [key: string]: IconType } = {
pc: FaWindows,
playstation: FaPlaystation,
xbox: FaXbox,
nintedo: SiNintendo,
mac: FaApple,
linux: FaLinux,
andriod: FaAndroid,
ios: MdPhoneIphone,
web: BsGlobe,
};
return (
<HStack>
{platforms.map((platform) => (
<Icon key={platform.id} as={iconMap[platform.slug]} />
// <Text key={platform.id}>{platform.slug}</Text>
))}
</HStack>
);
};
export default PlatformIconList;
The Text
object works without a problem however, moving to the Icons
seems to trigger an error that I am not experienced enough to understand it or figure out how to fix it.
Any ideas?