Chat.js 1.02 KB
Newer Older
Choi Ga Young's avatar
Choi Ga Young committed
1
import React from 'react';
2
import { Form, Button, Row } from 'react-bootstrap';
우지원's avatar
ul    
우지원 committed
3
4
5


function Chat(props) {
JeongYeonwoo's avatar
D    
JeongYeonwoo committed
6
7
  let defaultname=''
  // let defaultname = sessionStorage.getItem('name');
JeongYeonwoo's avatar
JeongYeonwoo committed
8

9
10
11
12
13
14
15
16
17
18
  function handleChange(e) {
    e.preventDefault()
    props.setInner(e.target.value)
    console.log(e.target.value)
  }

  function sendMsgCH(e) {
    props.sendMsg(e)
  }

Choi Ga Young's avatar
aa    
Choi Ga Young committed
19

우지원's avatar
ul    
우지원 committed
20
  return (
JeongYeonwoo's avatar
JeongYeonwoo committed
21

우지원's avatar
ul    
우지원 committed
22
23
    <div className="chat" id="chat" style={{ border: "2px solid", height: "300%", margin: "1%", borderColor: "#BDBDBD" }}>
      <Button variant="light" onClick={props.handleChatc} >{`<`}</Button>
Choi Ga Young's avatar
aa    
Choi Ga Young committed
24

25
26
27
      <h2>현재 {props.roomName} 입니다.</h2>
      {      props.chatmsg.map((value, index) => (
        <Row key={index} className='ml-3'>
JeongYeonwoo's avatar
D    
JeongYeonwoo committed
28
          {props.roomName}에서 {props.namelist}님이 보낸 메세지 : {value}
29
30
31
32
33
34
35
        </Row>
      ))}

      <Form onSubmit={sendMsgCH}>
        <Form.Control name='msg' type='text' onChange={handleChange} />
        <Button variant="primary" type="submit">전송</Button>
      </Form>
우지원's avatar
ul    
우지원 committed
36
37
38
39
40
41
42
    </div>


  );
}

export default Chat;