Overnap

방이 하나도 없을 때 안내 메세지 추가

...@@ -28,7 +28,12 @@ const Rooms: React.FC = () => { ...@@ -28,7 +28,12 @@ const Rooms: React.FC = () => {
28 }); 28 });
29 }, []); 29 }, []);
30 30
31 - useEffect(refreshRooms, []); 31 + useEffect(() => {
32 + // 뒤로가기 키로 빠져나오면 ping listener를 unsubscribe
33 + socket.off('ping');
34 +
35 + refreshRooms();
36 + }, []);
32 37
33 return ( 38 return (
34 <Main> 39 <Main>
...@@ -37,7 +42,11 @@ const Rooms: React.FC = () => { ...@@ -37,7 +42,11 @@ const Rooms: React.FC = () => {
37 <Create /> 42 <Create />
38 </div> 43 </div>
39 <div className='mt-auto w-screen flex flex-col items-center'> 44 <div className='mt-auto w-screen flex flex-col items-center'>
40 - {rooms.map((room) => (<RoomBlock key={room.uuid} room={room} />))} 45 + {
46 + rooms.length > 0 ?
47 + rooms.map((room) => (<RoomBlock key={room.uuid} room={room} />))
48 + : (<div className='text-lg'>There's no room at all.</div>)
49 + }
41 </div> 50 </div>
42 </Main> 51 </Main>
43 ) 52 )
......