ClosedList.js 852 Bytes
Newer Older
Choi Ga Young's avatar
Choi Ga Young committed
1
import React, { useState } from 'react'
2
import { ListGroup, Row, Col } from 'react-bootstrap';
Choi Ga Young's avatar
Choi Ga Young committed
3

4
function ClosedList(props) {
Choi Ga Young's avatar
Choi Ga Young committed
5
6
7
8
  const [list, setList] = useState([
    { room: '테스트 방1', memnum: 5, admin: '가영' },
    { room: '테스트 방2', memnum: 4, admin: '수현' }]
  );
Soo Hyun Kim's avatar
soo0115    
Soo Hyun Kim committed
9

10
  function enterChatroomCH(e) {
Soo Hyun Kim's avatar
soo0115    
Soo Hyun Kim committed
11
12
    console.log(e.target.name)
    console.log(e.target)
13
14
15
    const roomName = e.target.name
    props.enterChatroom(roomName) // 각각의 room으로 들어가도록 설정해야 함
    props.setRoomName(roomName)
Soo Hyun Kim's avatar
soo0115    
Soo Hyun Kim committed
16
    // props.clearChat()
17
18
  }

Choi Ga Young's avatar
Choi Ga Young committed
19
20
  return (
    <div>
Soo Hyun Kim's avatar
soo0115    
Soo Hyun Kim committed
21
      {list.map((item, index) =>
Choi Ga Young's avatar
Choi Ga Young committed
22
        <ListGroup key={index}>
23
          <ListGroup.Item action onClick={enterChatroomCH} name={item.room}>
Soo Hyun Kim's avatar
soo0115    
Soo Hyun Kim committed
24
          {item.room}
Choi Ga Young's avatar
Choi Ga Young committed
25
26
27
28
29
30
31
32
          </ListGroup.Item>
        </ListGroup>
      )}
    </div>
  )
}

export default ClosedList