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-09 20:43:46 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a5ddd90714ad687e8b7f0570bbec856c3a08d36d
a5ddd907
1 parent
77863a84
방으로 이동할 때에도 username을 히스토리에 기록
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
web/src/components/rooms/RoomBlock.tsx
web/src/components/rooms/RoomBlock.tsx
View file @
a5ddd90
import React, { useCallback, useContext } from 'react';
import { useHistory } from 'react-router';
import { useHistory
, useLocation
} from 'react-router';
import SocketContext from '../../contexts/SocketContext';
import { MessageResponse, MessageType, RawMessage } from '../common/types';
import { RoomData } from '../room/types';
import { Room } from './types';
interface RoomBlockLocation {
state: { username: string }
}
interface RoomBlockProps {
room: Room
}
...
...
@@ -12,6 +16,8 @@ interface RoomBlockProps {
export const RoomBlock: React.FC<RoomBlockProps> = ({ room }) => {
const history = useHistory();
const socket = useContext(SocketContext);
const location: RoomBlockLocation = useLocation();
const joinRoom = useCallback(() => {
if (room.currentUsers < room.maxUsers) {
const rawMessage: RawMessage = {
...
...
@@ -22,7 +28,10 @@ export const RoomBlock: React.FC<RoomBlockProps> = ({ room }) => {
if (response.ok) {
history.push({
pathname: '/' + room.uuid,
state: {roomData: response.result!}
state: {
username: location.state.username,
roomData: response.result!
}
});
} else {
//TODO: 에러 MODAL을 어케띄우지? 하위컴포넌트에서 훅을 쓰면 어떻게 되는지 확인
...
...
Please
register
or
login
to post a comment