import { useEffect, useState } from "react"; import { useParams } from "react-router"; import roomApi from '../../apis/room.api'; import catchErrors from '../../context/catchError'; const INIT_ROOM = { profileimg: "", }; const RoomHeader = () => { const {roomId, channelId}=useParams(); const [room, setRoom] = useState([INIT_ROOM]); const [error, setError] = useState("") async function getRoom(Id) { try { const Room = await roomApi.getRoom([Id]); setRoom({profileimg: Room[0].profileimg}) console.log(room) } catch (error) { catchErrors(error, setError); } } useEffect(() => { getRoom(roomId); }, [roomId]); return (
) } export default RoomHeader