import { useEffect, useState } from "react"; import { Link, useParams } from "react-router-dom"; import roomApi from "../../apis/room.api"; import userApi from "../../apis/user.api"; import catchErrors from "../../context/catchError"; const id = localStorage.getItem("user"); const INIT_ROOM = { roomId: "", name: "", profileimg: "", member: "", }; const RoomSingle = () => { const [room, setRoom] = useState([INIT_ROOM]); const [error, setError] = useState(""); const channelId = "main"; const { roomId } = useParams(room.roomId); async function getJoinRoom(Id) { try { const User = await userApi.getUser(Id); const RoomNumArr = User.roomNumber; const Room = await roomApi.getRoom(RoomNumArr); let roomlist = []; for (let prop in Room) { roomlist.push({ roomId: Room[prop].id, name: Room[prop].name, profileimg: Room[prop].profileimg, member: Room[prop].member.length, }); } setRoom(roomlist); } catch (error) { catchErrors(error, setError); } } useEffect(() => { getJoinRoom(id); }, [id]); const { profileimg } = room; return (