import { useEffect, useState } from "react"; import catchErrors from "../../context/catchError"; import { useParams } from "react-router-dom"; import roomApi from "../../apis/room.api"; const INIT_ROOM = { id: "", name: "", profileimg: "", }; const InitRoom = () => { const { roomId } = useParams(); const [room, setRoom] = useState(INIT_ROOM); const [error, setError] = useState(""); async function getRoom(roomId) { try { const data = await roomApi.getRoom([roomId]); console.log(data) setRoom({...room, id:data[0].id, name:data[0].name, profileimg: data[0].profileimg}) console.log(room.profileimg) } catch (error) { catchErrors(error, setError); } } useEffect(() => { getRoom(roomId); }, [roomId]); return (

방 이름

{room.name}

방 코드

{room.id}

); }; export default InitRoom;