Toggle navigation
Toggle navigation
This project
Loading...
Sign in
강동현
/
nodejs-game
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Overnap
2021-06-07 05:02:06 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
73e2119b70e0898f6b2cbc4081d2c20b5803eade
73e2119b
1 parent
cba53238
Chat 컴포넌트 추가
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
web/src/components/room/Chat.tsx
web/src/components/room/Chat.tsx
0 → 100644
View file @
73e2119
import React, { useContext, useEffect, useState } from 'react';
import SocketContext from '../../contexts/SocketContext';
import { MessageType, RawMessage } from '../common/types';
import { ChatData } from './types';
export const Chat: React.FC = () => {
const socket = useContext(SocketContext);
const [ input, setInput ] = useState('');
const [ chatLines, setChatLines ] = useState<ChatData[]>([]);
useEffect(() => {
socket.on(MessageType.ROOM_CHAT, (data: ChatData) => {
setChatLines([...chatLines, data]);
});
return () => {
socket.off(MessageType.ROOM_CHAT);
}
}, []);
return (
<div className='w-2/12 h-60 rounded shadow'>
{chatLines.map((line) => (<div/>))}
<input className='w-5/6 px-3 py-2 bg-white
placeholder-gray-400 text-gray-700 text-sm
rounded shadow outline-none focus:outline-none'
onChange={e => setInput(e.target.value)}></input>
</div>
);
}
\ No newline at end of file
Please
register
or
login
to post a comment