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

Soo Hyun Kim's avatar
soo0115    
Soo Hyun Kim committed
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
11
12
13
14
15
16
17
18

  function enterChatroomCH(e) {
    console.log(e.target.name)
    console.log(e.target)
    const roomName = e.target.name
    props.enterChatroom(roomName) // 각각의 room으로 들어가도록 설정해야 함
    props.setRoomName(roomName)
    // props.clearChat()
  }

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}>
Soo Hyun Kim's avatar
soo0115    
Soo Hyun Kim committed
23
24
          <ListGroup.Item action onClick={enterChatroomCH} id='diddkdk' name={item.room}>
          {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