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-31 05:22:21 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
de1939df8d35b8c4dc23cdf813df6e7ac8d81717
de1939df
1 parent
593301c2
방 목록의 배열을 방 정보 컴포넌트에 매핑 및 테스트
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
4 deletions
web/src/pages/Rooms.tsx
web/src/pages/Rooms.tsx
View file @
de1939d
...
...
@@ -10,6 +10,24 @@ export const Rooms: React.FC<RouteComponentProps> = ({ history }) => {
const socket = useContext(SocketContext);
const [ rooms, setRooms ] = useState<Room[]>([]);
// for test
const testingRoom1: Room = {
uuid: '23525',
name: 'Hello World!',
currentUsers: 3,
maxUsers: 4
}
const testingRoom2: Room = {
uuid: '235252134',
name: 'Bonjour World!',
currentUsers: 6,
maxUsers: 6
}
useEffect(() => {
setRooms([testingRoom1, testingRoom2]);
// refreshRooms()
}, []);
const refreshRooms = () => {
socket.emit(MessageType.ROOM_LIST_REQUEST, (response: MessageResponse<Room[]>) => {
if (response.ok) {
...
...
@@ -21,14 +39,12 @@ export const Rooms: React.FC<RouteComponentProps> = ({ history }) => {
});
}
useEffect(refreshRooms, []);
//
useEffect(refreshRooms, []);
return (
<div className='flex flex-col items-center w-screen h-screen'>
<div className='mt-auto w-screen flex flex-col items-center'>
<RoomInfo name='테스트테스트' currentUsers={3} maxUsers={9} uuid='234234'></RoomInfo>
<RoomInfo name='테스트테스트' currentUsers={5} maxUsers={9} uuid='234234'></RoomInfo>
<RoomInfo name='테스트테스트' currentUsers={9} maxUsers={9} uuid='234234'></RoomInfo>
{rooms.map((room) => (<RoomInfo key={room.uuid} room={room} />))}
</div>
<Footer />
</div>
...
...
Please
register
or
login
to post a comment