import React, { useState } from 'react' import axios from 'axios'; import { Row, Col, Modal, Button, Form } from 'react-bootstrap'; import catchErrors from '../utils/catchErrors' function EnterRoom(props) { const [enterCode, setEnterCode] = useState(''); const [error, setError] = useState(''); const userId = sessionStorage.getItem('userId'); //sessionStorage에 저장된 userId가져옴 function handleChange(event) { const { name, value } = event.target setEnterCode(value) console.log(enterCode) } async function handleSubmit(event) { event.preventDefault() try { setError('') let res = await axios.post('/room/enterRoom', { enterCode }) await axios.put('/room/member', { userId: userId, roomId: enterCode }) props.setRoomName(res.data) props.setRoomCode(enterCode) props.enterChatRoom(enterCode) props.handleCloseEnter() props.handleChato() setEnterCode('') } catch (error){ catchErrors(error, setError) } } return ( <> 참여 코드로 채팅 참가
참여 코드
) } export default EnterRoom