Showing
1 changed file
with
3 additions
and
3 deletions
1 | -import React, { useContext, useEffect, useState } from 'react'; | 1 | +import React, { useCallback, useContext, useEffect, useState } from 'react'; |
2 | import { Main } from '../components/common/Main'; | 2 | import { Main } from '../components/common/Main'; |
3 | import { MessageResponse, MessageType } from '../components/common/types'; | 3 | import { MessageResponse, MessageType } from '../components/common/types'; |
4 | import { RoomBlock } from '../components/rooms/RoomBlock'; | 4 | import { RoomBlock } from '../components/rooms/RoomBlock'; |
... | @@ -9,7 +9,7 @@ export const Rooms: React.FC = () => { | ... | @@ -9,7 +9,7 @@ export const Rooms: React.FC = () => { |
9 | const socket = useContext(SocketContext); | 9 | const socket = useContext(SocketContext); |
10 | const [ rooms, setRooms ] = useState<Room[]>([]); | 10 | const [ rooms, setRooms ] = useState<Room[]>([]); |
11 | 11 | ||
12 | - const refreshRooms = () => { | 12 | + const refreshRooms = useCallback(() => { |
13 | socket.emit(MessageType.ROOM_LIST_REQUEST, (response: MessageResponse<Room[]>) => { | 13 | socket.emit(MessageType.ROOM_LIST_REQUEST, (response: MessageResponse<Room[]>) => { |
14 | if (response.ok) { | 14 | if (response.ok) { |
15 | setRooms(response.result!); | 15 | setRooms(response.result!); |
... | @@ -18,7 +18,7 @@ export const Rooms: React.FC = () => { | ... | @@ -18,7 +18,7 @@ export const Rooms: React.FC = () => { |
18 | console.log("방 목록을 수신하지 못함"); | 18 | console.log("방 목록을 수신하지 못함"); |
19 | } | 19 | } |
20 | }); | 20 | }); |
21 | - } | 21 | + }, []); |
22 | 22 | ||
23 | useEffect(refreshRooms, []); | 23 | useEffect(refreshRooms, []); |
24 | 24 | ... | ... |
-
Please register or login to post a comment