import React, { useState, useEffect } from 'react'; import { Form, Button, Row } from 'react-bootstrap'; function Chat(props) { // let defaultname='' let defaultname = sessionStorage.getItem('name'); const [inner, setInner] = useState(['']) const [chat, setChat] = useState([inner]) //object로 key는 보낸사람 value는 메세지 function handleChange(e) { e.preventDefault() setInner(e.target.value) console.log(e.target.value) } function sendMsgCH(e) { e.preventDefault() props.setSingleChat(inner) props.sendMsg(e) setInner('') } useEffect(() => { setChat([...chat, props.singleChat]) }, [props.singleChat]) useEffect(() => { setChat([...chat, props.recievedMsg]) }, [props.recievedMsg]) return (