import { useEffect, useState } from 'react'; import { Link } 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={ name:"", profileimg:"", member:"", } const RoomSingle = () => { const [room, setRoom] = useState(INIT_ROOM) const [error,setError]=useState('') const channelId = 1 async function getJoinRoom(Id) { try { const User = await userApi.getUser(Id) const RoomNumArr = User.roomNumber const Room= await roomApi.getRoom(RoomNumArr) console.log(Room[0]) const rrr=Room[0] const memcount= rrr.member.length setRoom({...room, name:rrr.name, profileimg: rrr.profileimg, member:memcount}) console.log(room) } catch (error) { catchErrors(error, setError) } } useEffect(() => { getJoinRoom(id) }, [id]) return (