Showing
1 changed file
with
20 additions
and
4 deletions
... | @@ -10,6 +10,24 @@ export const Rooms: React.FC<RouteComponentProps> = ({ history }) => { | ... | @@ -10,6 +10,24 @@ export const Rooms: React.FC<RouteComponentProps> = ({ history }) => { |
10 | const socket = useContext(SocketContext); | 10 | const socket = useContext(SocketContext); |
11 | const [ rooms, setRooms ] = useState<Room[]>([]); | 11 | const [ rooms, setRooms ] = useState<Room[]>([]); |
12 | 12 | ||
13 | + // for test | ||
14 | + const testingRoom1: Room = { | ||
15 | + uuid: '23525', | ||
16 | + name: 'Hello World!', | ||
17 | + currentUsers: 3, | ||
18 | + maxUsers: 4 | ||
19 | + } | ||
20 | + const testingRoom2: Room = { | ||
21 | + uuid: '235252134', | ||
22 | + name: 'Bonjour World!', | ||
23 | + currentUsers: 6, | ||
24 | + maxUsers: 6 | ||
25 | + } | ||
26 | + useEffect(() => { | ||
27 | + setRooms([testingRoom1, testingRoom2]); | ||
28 | + // refreshRooms() | ||
29 | + }, []); | ||
30 | + | ||
13 | const refreshRooms = () => { | 31 | const refreshRooms = () => { |
14 | socket.emit(MessageType.ROOM_LIST_REQUEST, (response: MessageResponse<Room[]>) => { | 32 | socket.emit(MessageType.ROOM_LIST_REQUEST, (response: MessageResponse<Room[]>) => { |
15 | if (response.ok) { | 33 | if (response.ok) { |
... | @@ -21,14 +39,12 @@ export const Rooms: React.FC<RouteComponentProps> = ({ history }) => { | ... | @@ -21,14 +39,12 @@ export const Rooms: React.FC<RouteComponentProps> = ({ history }) => { |
21 | }); | 39 | }); |
22 | } | 40 | } |
23 | 41 | ||
24 | - useEffect(refreshRooms, []); | 42 | + // useEffect(refreshRooms, []); |
25 | 43 | ||
26 | return ( | 44 | return ( |
27 | <div className='flex flex-col items-center w-screen h-screen'> | 45 | <div className='flex flex-col items-center w-screen h-screen'> |
28 | <div className='mt-auto w-screen flex flex-col items-center'> | 46 | <div className='mt-auto w-screen flex flex-col items-center'> |
29 | - <RoomInfo name='테스트테스트' currentUsers={3} maxUsers={9} uuid='234234'></RoomInfo> | 47 | + {rooms.map((room) => (<RoomInfo key={room.uuid} room={room} />))} |
30 | - <RoomInfo name='테스트테스트' currentUsers={5} maxUsers={9} uuid='234234'></RoomInfo> | ||
31 | - <RoomInfo name='테스트테스트' currentUsers={9} maxUsers={9} uuid='234234'></RoomInfo> | ||
32 | </div> | 48 | </div> |
33 | <Footer /> | 49 | <Footer /> |
34 | </div> | 50 | </div> | ... | ... |
-
Please register or login to post a comment