Overnap
Builds for 1 pipeline failed in 1 minute 18 seconds

비정상적인 루트로 방에 들어오면 로그인으로 강제 전송 추가

1 import React, { useCallback, useContext, useEffect, useState } from 'react'; 1 import React, { useCallback, useContext, useEffect, useState } from 'react';
2 -import { useLocation, useParams } from 'react-router'; 2 +import { useHistory, useLocation } from 'react-router';
3 import SocketContext from '../../contexts/SocketContext'; 3 import SocketContext from '../../contexts/SocketContext';
4 import { MessageResponse, MessageType, RawMessage } from '../common/types'; 4 import { MessageResponse, MessageType, RawMessage } from '../common/types';
5 import { RoomData, UpdateRoomUser } from './types'; 5 import { RoomData, UpdateRoomUser } from './types';
...@@ -9,6 +9,7 @@ interface RoomInfoLocation { ...@@ -9,6 +9,7 @@ interface RoomInfoLocation {
9 } 9 }
10 10
11 export const RoomInfo: React.FC = () => { 11 export const RoomInfo: React.FC = () => {
12 + const history = useHistory();
12 const socket = useContext(SocketContext); 13 const socket = useContext(SocketContext);
13 const location: RoomInfoLocation = useLocation(); 14 const location: RoomInfoLocation = useLocation();
14 15
...@@ -54,6 +55,12 @@ export const RoomInfo: React.FC = () => { ...@@ -54,6 +55,12 @@ export const RoomInfo: React.FC = () => {
54 }, [roomData]); 55 }, [roomData]);
55 56
56 useEffect(() => { 57 useEffect(() => {
58 + // 비정상적인 루트로 방을 들어오면 로그인 화면으로 푸시
59 + if (location.state === undefined) {
60 + history.push('/');
61 + return;
62 + }
63 +
57 setRoomData(location.state.roomData); 64 setRoomData(location.state.roomData);
58 65
59 return () => { 66 return () => {
......