Overnap

RouteComponentProps 대신 Context를 사용하도록 변경

1 import React, { useContext, useState } from 'react'; 1 import React, { useContext, useState } from 'react';
2 -import { RouteComponentProps } from 'react-router'; 2 +import { useHistory } from 'react-router';
3 import { Main } from '../components/common/Main'; 3 import { Main } from '../components/common/Main';
4 import { MessageResponse, MessageType } from '../components/common/types'; 4 import { MessageResponse, MessageType } from '../components/common/types';
5 import SocketContext from '../contexts/SocketContext'; 5 import SocketContext from '../contexts/SocketContext';
6 6
7 -export const Login: React.FC<RouteComponentProps> = ({ history }) => { 7 +export const Login: React.FC = () => {
8 + const history = useHistory();
8 const socket = useContext(SocketContext); 9 const socket = useContext(SocketContext);
9 const [ username, setUsername ] = useState(""); 10 const [ username, setUsername ] = useState("");
10 11
......
1 import React, { useContext, useEffect, useState } from 'react'; 1 import React, { useContext, useEffect, useState } from 'react';
2 -import { RouteComponentProps } from 'react-router';
3 import { Main } from '../components/common/Main'; 2 import { Main } from '../components/common/Main';
4 import { MessageResponse, MessageType } from '../components/common/types'; 3 import { MessageResponse, MessageType } from '../components/common/types';
5 import { RoomInfo } from '../components/rooms/RoomInfo'; 4 import { RoomInfo } from '../components/rooms/RoomInfo';
6 import { Room } from '../components/rooms/types'; 5 import { Room } from '../components/rooms/types';
7 import SocketContext from '../contexts/SocketContext'; 6 import SocketContext from '../contexts/SocketContext';
8 7
9 -export const Rooms: React.FC<RouteComponentProps> = ({ history }) => { 8 +export const Rooms: React.FC = () => {
10 const socket = useContext(SocketContext); 9 const socket = useContext(SocketContext);
11 const [ rooms, setRooms ] = useState<Room[]>([]); 10 const [ rooms, setRooms ] = useState<Room[]>([]);
12 11
......