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:12:22 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6efee08ac31a0dfc56ecde376a3f25a55c60d22b
6efee08a
1 parent
f1b846e3
리액트 훅의 dependency 해소
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
web/src/components/room/GameBoard.tsx
web/src/components/room/Ready.tsx
web/src/components/room/GameBoard.tsx
View file @
6efee08
...
...
@@ -4,7 +4,7 @@ import SocketContext from '../../contexts/SocketContext';
import { MessageType, RawMessage } from '../common/types';
import { Canvas } from './Canvas';
import { RoundInfo } from './RoundInfo';
import { Ro
le, Ro
undData } from './types';
import { RoundData } from './types';
import { Word } from './Word';
interface GameBoardLocation {
...
...
@@ -37,8 +37,8 @@ export const GameBoard: React.FC<GameBoardProps> = ({ isInGame }) => {
setWords([]);
const data = rawMessage.message as RoundData;
console.log('테스트 location ',
location.state.username);
console.log('테스트 rolse ',
data.roles);
// console.log(
location.state.username);
// console.log(
data.roles);
const index = data.roles.findIndex(x => x.username === location.state.username);
setIsDrawer(data.roles[index].role === 'drawer');
setWordChosen('');
...
...
@@ -64,18 +64,24 @@ export const GameBoard: React.FC<GameBoardProps> = ({ isInGame }) => {
useEffect(() => {
socket.on('msg', handleStart);
socket.on('msg', handleGetWordLength);
socket.on('msg', handleWordSet);
socket.on('msg', handleAnswer);
return () => {
socket.off('msg', handleStart);
socket.off('msg', handleGetWordLength);
socket.off('msg', handleWordSet);
socket.off('msg', handleAnswer);
}
}, []);
useEffect(() => {
socket.on('msg', handleGetWordLength);
return () => {
socket.off('msg', handleGetWordLength);
}
}, [wordChosen]);
return (
<div className={`w-auto ${isInGame ? '' : 'hidden'}`}>
<div className='w-full flex flex-col justify-center items-center'>
...
...
web/src/components/room/Ready.tsx
View file @
6efee08
...
...
@@ -28,7 +28,7 @@ export const Ready: React.FC<ReadyProps> = ({ users }) => {
var test = users.length > 1;
users.forEach(x => test = test && (x.ready || x.admin));
setIsAllReady(test);
});
}
, [users, location.state.username]
);
const handleReady = useCallback(() => {
if (isAdmin && isAllReady) {
...
...
Please
register
or
login
to post a comment