Commit 2fb46987 authored by Yoon, Daeki's avatar Yoon, Daeki 😅
Browse files

chat inner debut

parent 0a02c1c5
...@@ -6,7 +6,7 @@ function Chat(props) { ...@@ -6,7 +6,7 @@ function Chat(props) {
let defaultname = sessionStorage.getItem('name'); let defaultname = sessionStorage.getItem('name');
const [inner, setInner] = useState(['']) const [inner, setInner] = useState([''])
const [chat, setChat] = useState([inner]) //object로 key는 보낸사람 value는 메세지 const [chat, setChat] = useState([]) //object로 key는 보낸사람 value는 메세지
function handleChange(e) { function handleChange(e) {
e.preventDefault() e.preventDefault()
...@@ -33,9 +33,10 @@ function Chat(props) { ...@@ -33,9 +33,10 @@ function Chat(props) {
<div className="chat" id="chat" style={{ border: "2px solid", height: "300%", margin: "1%", borderColor: "#BDBDBD" }}> <div className="chat" id="chat" style={{ border: "2px solid", height: "300%", margin: "1%", borderColor: "#BDBDBD" }}>
<h2>현재 {props.roomName} 입니다.</h2> <h2>현재 {props.roomName} 입니다.</h2>
{ chat.map((value, index) => { {console.log(chat)}
if (!(value=='')) { {chat.map((value, index) => {
// console.log(`value=${value}=`) if (!(value === '')) {
console.log('value=', value)
return <Row key={index} className='ml-3'> return <Row key={index} className='ml-3'>
{props.roomName}에서 {defaultname}님이 보낸 메세지 : {value} {props.roomName}에서 {defaultname}님이 보낸 메세지 : {value}
</Row> </Row>
......
...@@ -24,7 +24,7 @@ function ClosedList(props) { ...@@ -24,7 +24,7 @@ function ClosedList(props) {
console.log(e.target.name) console.log(e.target.name)
console.log(e.target) console.log(e.target)
const roomName = e.target.name const roomName = e.target.name
props.enterChatroom(roomName) // 각각의 room으로 들어가도록 설정해야 함 props.enterChatRoom(roomName) // 각각의 room으로 들어가도록 설정해야 함
props.setRoomName(roomName) props.setRoomName(roomName)
} }
......
...@@ -36,7 +36,7 @@ function Home() { ...@@ -36,7 +36,7 @@ function Home() {
//SOCKET 관련 시작 //SOCKET 관련 시작
function enterChatroom(rName) { //방 입장하기 function enterChatRoom(rName) { //방 입장하기
socket.emit('joinRoom', rName) socket.emit('joinRoom', rName)
console.log(`joinRoom : ${rName} 입장`) console.log(`joinRoom : ${rName} 입장`)
} }
...@@ -92,7 +92,7 @@ function Home() { ...@@ -92,7 +92,7 @@ function Home() {
</Col> </Col>
</Row> </Row>
<RoomMake showModal={showModal} handleCloseModal={handleCloseModal} /> <RoomMake showModal={showModal} handleCloseModal={handleCloseModal} />
<EnterRoom showEnter={showEnter} enterChatRoom={enterChatroom} handleCloseEnter={handleCloseEnter} /> <EnterRoom showEnter={showEnter} enterChatRoom={enterChatRoom} handleCloseEnter={handleCloseEnter} />
</> </>
); );
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment