patch useEffect dependencies on Game page
This commit is contained in:
parent
7aed5b7bf9
commit
155cca9110
4 changed files with 7 additions and 6 deletions
|
@ -3,7 +3,7 @@ import './Board.scss';
|
||||||
import Point from '../Point/Point';
|
import Point from '../Point/Point';
|
||||||
|
|
||||||
const Board = (props) => {
|
const Board = (props) => {
|
||||||
const { game, user, dispatch, board } = props;
|
const { game, user, dispatch, board, meta } = props;
|
||||||
const sizeFlag = `Game__board--size-${ game.boardSize }`
|
const sizeFlag = `Game__board--size-${ game.boardSize }`
|
||||||
|
|
||||||
const renderPoints = boardSize => {
|
const renderPoints = boardSize => {
|
||||||
|
|
|
@ -2,8 +2,8 @@ import React from 'react';
|
||||||
import './Point.scss';
|
import './Point.scss';
|
||||||
|
|
||||||
const Point = (props) => {
|
const Point = (props) => {
|
||||||
const { posX, posY, user, game, dispatch, pointData } = props;
|
const { posX, posY, user, game, meta, dispatch, pointData } = props;
|
||||||
const turn = game.turn > 0 ? 'black' : 'white';
|
const turn = meta && meta.turn ? meta.turn > 0 ? 'black' : 'white' : game.turn > 0 ? 'black' : 'white';
|
||||||
|
|
||||||
const stone = () => {
|
const stone = () => {
|
||||||
if (pointData === 1) return 'black'
|
if (pointData === 1) return 'black'
|
||||||
|
|
|
@ -39,7 +39,7 @@ const Game = (props) => {
|
||||||
return dispatch(action);
|
return dispatch(action);
|
||||||
}
|
}
|
||||||
roomSocketConnect();
|
roomSocketConnect();
|
||||||
}, [ state.active.game.open , dispatch, state.user ] )
|
}, [ state.active.game, dispatch, state.user ] )
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
@ -59,7 +59,8 @@ const Game = (props) => {
|
||||||
<PlayerArea />
|
<PlayerArea />
|
||||||
<Board
|
<Board
|
||||||
dispatch={dispatch}
|
dispatch={dispatch}
|
||||||
game={state.active.game}
|
game={state.active.game}
|
||||||
|
meta={state.meta}
|
||||||
record={state.active.record}
|
record={state.active.record}
|
||||||
user={state.user}
|
user={state.user}
|
||||||
board={state.board}
|
board={state.board}
|
||||||
|
|
|
@ -21,7 +21,7 @@ export const gamesReducer = (state, action) => {
|
||||||
|
|
||||||
case 'UPDATE_BOARD':
|
case 'UPDATE_BOARD':
|
||||||
const { gameRecord, pass, turn, winner, playerState } = action.body.meta;
|
const { gameRecord, pass, turn, winner, playerState } = action.body.meta;
|
||||||
return {...state, board: action.body.board, active: { game: {...state.active.game, gameRecord, pass, turn, winner, playerState } } };
|
return {...state, board: action.body.board, meta: {gameRecord, pass, turn, winner, playerState } };
|
||||||
|
|
||||||
case 'SET_ACTIVE':
|
case 'SET_ACTIVE':
|
||||||
return {...state, active: action.body};
|
return {...state, active: action.body};
|
||||||
|
|
Loading…
Reference in a new issue