Overnap

refreshRooms를 useCallback 훅으로 변경

import React, { useContext, useEffect, useState } from 'react';
import React, { useCallback, useContext, useEffect, useState } from 'react';
import { Main } from '../components/common/Main';
import { MessageResponse, MessageType } from '../components/common/types';
import { RoomBlock } from '../components/rooms/RoomBlock';
......@@ -9,7 +9,7 @@ export const Rooms: React.FC = () => {
const socket = useContext(SocketContext);
const [ rooms, setRooms ] = useState<Room[]>([]);
const refreshRooms = () => {
const refreshRooms = useCallback(() => {
socket.emit(MessageType.ROOM_LIST_REQUEST, (response: MessageResponse<Room[]>) => {
if (response.ok) {
setRooms(response.result!);
......@@ -18,7 +18,7 @@ export const Rooms: React.FC = () => {
console.log("방 목록을 수신하지 못함");
}
});
}
}, []);
useEffect(refreshRooms, []);
......