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-05-27 01:14:00 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5a5bac9939636cbd8c4f733f079572ea179efcd1
5a5bac99
1 parent
2080b073
(WIP) 방 목록 컴포넌트 추가
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletions
web/src/App.tsx
web/src/Rooms.tsx
web/src/App.tsx
View file @
5a5bac9
...
...
@@ -2,6 +2,7 @@ import React from 'react';
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom';
import { socket, SocketProvider } from './SocketContext';
import { Login } from './Login';
import { Rooms } from './Rooms';
const App: React.FC = () => {
return (
...
...
@@ -9,7 +10,7 @@ const App: React.FC = () => {
<Router>
<Switch>
<Route exact path='/' component={Login}/>
<Route path='/rooms'></Route>
<Route path='/rooms'
component={Rooms}
></Route>
<Route path='/:roomId'></Route>
</Switch>
</Router>
...
...
web/src/Rooms.tsx
0 → 100644
View file @
5a5bac9
import React, { useContext, useEffect, useState } from 'react';
import { RouteComponentProps } from 'react-router';
import SocketContext from './SocketContext';
interface room {
uuid: string;
name: string;
currentUsers: number;
maxUsers: number;
}
export const Rooms: React.FC<RouteComponentProps> = ({ history }) => {
const socket = useContext(SocketContext);
const [ rooms, setRooms ] = useState<room[]>([]);
useEffect(() => {
socket.emit('room_list', ({ ok } : { ok: boolean }) => {
if (ok) {
history.push('/rooms');
} else {
console.error('login error!'); // TODO: 팝업 에러?
}
}); // TODO: interval마다 emit하거나 새로고침 버튼을 만들자
// socket.on('')
}, []);
return (
<div>
<header>header header</header>
<div className='flex items-center'>
<div>room test</div>
</div>
<footer>footer footer</footer>
</div>
)
}
\ No newline at end of file
Please
register
or
login
to post a comment