OpenList.js 785 Bytes
Newer Older
우지원's avatar
ul    
우지원 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 OpenList(props) {
우지원's avatar
ul    
우지원 committed
5
6
7
8
  const [list, setList] = useState([
    { room: '테스트 방3', memnum: 7, admin: '가영2' },
    { room: '테스트 방4', memnum: 2, admin: '수현2' }]
  );
Soo Hyun Kim's avatar
soo0115    
Soo Hyun Kim committed
9

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

우지원's avatar
ul    
우지원 committed
17
18
19
20
  return (
    <div>
      {list.map((list, index) =>
        <ListGroup key={index}>
Soo Hyun Kim's avatar
Soo Hyun Kim committed
21
          <ListGroup.Item action onClick={enterChatRoomCH} name={list.room}>
Soo Hyun Kim's avatar
Soo Hyun Kim committed
22
            {list.room}
우지원's avatar
ul    
우지원 committed
23
24
25
26
27
28
29
30
          </ListGroup.Item>
        </ListGroup>
      )}
    </div>
  )
}

export default OpenList