Untitled conversation
- User
{socialLinks.map((link, index) => { return ( );Uncaught TypeError: socialLinks.map is not a function : import { useEffect, useState, useRef } from "react"; import { Link, useLocation } from "react-router-dom"; import BoutonReseau from "../../components/Artiste/BoutonReseau"; import { motion } from "framer-motion"; import axios from "axios";
export default function PageEvenement() { const location = useLocation(); const oldX = location.state?.oldX; const oldY = location.state?.oldY; const oldGroupes = location.state?.oldGroupes; const [nomArtiste, setNomArtiste] = useState(location.state?.nomArtiste); const [date, setDate] = useState(location.state?.date); const [heure, setHeure] = useState(location.state?.heure); const titleRef = useRef(null); const [description, setDescription] = useState( location.state?.description || "Description par défaut si aucune description n'est passée." ); const [socialLinks, setSocialLinks] = useState<{ reseau: string }[]>([]); const params = new URLSearchParams(window.location.search); const idArtiste = params.get("id");
const [windowWidth, setWindowWidth] = useState(window.innerWidth); const [infosGridPosition, setInfosGridPosition] = useState<"top" | "bottom">( "top" );
function getSocialNetworkType(url: string): "soundcloud" | "spotify" | "instagram" | "twitter" | "youtube" { if (url.includes("soundcloud")) { return "soundcloud"; } else if (url.includes("spotify")) { return "spotify"; } else if (url.includes("instagram")) { return "instagram"; } else if (url.includes("twitter")) { return "twitter"; } else if (url.includes("youtube")) { return "youtube"; } else { throw new Error(
Unsupported social network URL: ${url}); } }useEffect(() => { axios .get("http://localhost:8080/getSocialLinks/" + idArtiste) .then((response) => { setSocialLinks(response.data); console.log(response.data); }) .catch((error) => { console.error( "Erreur lors de la récupération des liens de réseaux sociaux", error ); });
const handleResize = () => { setWindowWidth(window.innerWidth); }; window.addEventListener("resize", handleResize); return () => { window.removeEventListener("resize", handleResize); };}, []);
useEffect(() => { if (titleRef.current) { // regarde si la width du titre est plus grande que 25% de la width de la fenetre - 2*3rem if (titleRef.current.offsetWidth > windowWidth / 4 - 2 * 3 * 16) { setInfosGridPosition("top"); } else { setInfosGridPosition("bottom"); } } }, [titleRef, windowWidth]);
const infosVariants = { initial: { opacity: 0, transition: { duration: 0.1, ease: "easeInOut", }, }, visible: { opacity: 1, transition: { delay: 0.8, duration: 0.6, ease: "easeInOut", }, }, };
const overlayVariants = { initial: { background: "linear-gradient(to top, rgba(0, 0, 0, 0.7) 20%, rgba(0, 0, 0, 0) 60%)", transition: { duration: 0.1, ease: "easeInOut", }, }, extended: { background: "linear-gradient(to top, rgba(0, 0, 0, 0.7) 40%, rgba(0, 0, 0, 0) 100%)", transition: { delay: 0.6, duration: 0.6, ease: "easeInOut", }, }, };
- Assistant
It seems like you have a JavaScript error
Uncaught TypeError: socialLinks.map is not a functionin your React component. This error indicates thatsocialLinks, which you're trying to iterate over with.map(), is not an array.The
.map()method is an array method which calls a provided function on every element within the array, but if is not an array, you'll receive this error.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.