Toggle navigation
Toggle navigation
This project
Loading...
Sign in
강동현
/
nodejs-game
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Overnap
2021-06-05 22:42:01 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7a060cbb1e2e2cf29e3ee550ffae1be3c7844776
7a060cbb
1 parent
9bad068d
refreshRooms를 useCallback 훅으로 변경
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
web/src/pages/Rooms.tsx
web/src/pages/Rooms.tsx
View file @
7a060cb
import React, { useContext, useEffect, useState } from 'react';
import React, { useC
allback, useC
ontext, 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, []);
...
...
Please
register
or
login
to post a comment