ChatForm.js 1.05 KB
Newer Older
Soo Hyun Kim's avatar
soo0115    
Soo Hyun Kim committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import React, { useState } from 'react';
import { Form, Row, Col, Button } from 'react-bootstrap'

function ChatForm(props) {
    const INIT_SAYING = ''
    const [saying, setSaying] = useState(INIT_SAYING);

    function handleChange(event) {
        const { name, value } = event.target
        setSaying(value)
        console.log(saying)
    }

    function handleSubmit(event) {
        event.preventDefault()
        // const response = await axios.post('chat/makeChat', chatR)
        props.setSingleChat()
        setSaying(INIT_SAYING)
    }

    return (
        <Form onSubmit={handleSubmit}>
            <Row>
                <Col>
                    <Form.Group>
                        <Form.Control name='chat' type='text' onChange={handleChange}>chat</Form.Control>
                    </Form.Group>
                </Col>
                <Col>
                    <Form.Group>
                        <Button type="submit">send</Button>
                    </Form.Group>
                </Col>
            </Row>
        </Form>
    )
}

export default ChatForm