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-10 08:21:47 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f5c9b2614b8db7ca136f1a607c03cd3f51154659
f5c9b261
1 parent
6efee08a
크게 중요하지 않은 의존성과 쓰이지 않는 변수에 대한 리팩토링
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
12 deletions
web/src/components/room/Word.tsx
web/src/components/rooms/Create.tsx
web/src/components/rooms/RoomBlock.tsx
web/src/pages/Login.tsx
web/src/pages/Room.tsx
web/src/components/room/Word.tsx
View file @
f5c9b26
import React, { useCallback, useContext } from 'react';
import { IndexType } from 'typescript';
import SocketContext from '../../contexts/SocketContext';
import { MessageResponse, MessageType, RawMessage } from '../common/types';
...
...
@@ -24,7 +23,7 @@ export const Word: React.FC<WordProps> = (props) => {
props.setWordChosen(props.word);
}
});
}, [props.setWordChosen]);
}, [props.
word, props.setWords, props.
setWordChosen]);
return (
<button className={`bg-green-500 active:bg-green-600 fixed
...
...
web/src/components/rooms/Create.tsx
View file @
f5c9b26
...
...
@@ -3,7 +3,6 @@ import { useHistory, useLocation } from 'react-router-dom';
import SocketContext from '../../contexts/SocketContext';
import { MessageResponse, MessageType, RawMessage } from '../common/types';
import { RoomData } from '../room/types';
import { Room } from './types';
interface CreateLocation {
state: { username: string }
...
...
@@ -33,7 +32,7 @@ export const Create: React.FC = () => {
console.log('방 생성 오류');
}
});
}, [roomName]);
}, [roomName
, location.state.username
]);
return (
<div className="flex items-center">
...
...
web/src/components/rooms/RoomBlock.tsx
View file @
f5c9b26
...
...
@@ -40,7 +40,7 @@ export const RoomBlock: React.FC<RoomBlockProps> = ({ room }) => {
} else {
//TODO: 자리 꽉찼다는 MODAL
}
}, []);
}, [
location.state.username, room
]);
return (
<button className={`flex items-center place-content-between m-2 w-5/6
...
...
web/src/pages/Login.tsx
View file @
f5c9b26
...
...
@@ -29,7 +29,7 @@ export const Login: React.FC = () => {
return (
<Main>
<div className="mt-auto flex flex-col items-center">
<img className="m-7" src="./logo192.png"/>
<img className="m-7" src="./logo192.png"
alt='logo img'
/>
<div>
<input type="text"
placeholder="Username"
...
...
web/src/pages/Room.tsx
View file @
f5c9b26
...
...
@@ -2,7 +2,6 @@ import React, { useCallback, useContext, useEffect, useState } from 'react';
import { useHistory, useLocation } from 'react-router';
import { Main } from '../components/common/Main';
import { MessageResponse, MessageType, RawMessage } from '../components/common/types';
import { Canvas } from '../components/room/Canvas';
import { Chat } from '../components/room/Chat';
import { GameBoard } from '../components/room/GameBoard';
import { Ready } from '../components/room/Ready';
...
...
@@ -10,7 +9,6 @@ import { RoomInfo } from '../components/room/RoomInfo';
import { RoomData, UpdateRoomUser } from '../components/room/types';
import { UserInfo } from '../components/room/UserInfo';
import { UserRole } from '../components/room/UserRole';
import { UserStatus } from '../components/room/UserStatus';
import SocketContext from '../contexts/SocketContext';
interface RoomLocation {
...
...
@@ -40,9 +38,9 @@ export const Room: React.FC = () => {
}, []);
const handleUpdateRoomUser = useCallback((rawMessage: RawMessage) => {
if (rawMessage.type == MessageType.ROOM_USER_UPDATE) {
if (rawMessage.type ==
=
MessageType.ROOM_USER_UPDATE) {
const data = rawMessage.message as UpdateRoomUser;
if (data.state == 'removed') {
if (data.state ==
=
'removed') {
const newUsers = roomData.users;
const index = newUsers.findIndex(x => x.username === data.user.username);
if (index < 0) {
...
...
@@ -81,7 +79,7 @@ export const Room: React.FC = () => {
return () => {
socket.off('msg', handleUpdateRoomUser);
}
}, [
roomData
]);
}, [
handleUpdateRoomUser
]);
useEffect(() => {
// 비정상적인 루트로 방을 들어오면 로그인 화면으로 푸시
...
...
@@ -102,7 +100,7 @@ export const Room: React.FC = () => {
}
socket.emit('msg', rawMessage, (response : MessageResponse<undefined>) => {});
}
}, [
])
}, [
location.state]);
return (
<Main>
...
...
Please
register
or
login
to post a comment