patch useEffect dependencies on Game page

This commit is contained in:
Sorrel Bri 2020-05-04 23:44:38 -07:00
parent 7aed5b7bf9
commit 155cca9110
4 changed files with 7 additions and 6 deletions

View file

@ -3,7 +3,7 @@ import './Board.scss';
import Point from '../Point/Point';
const Board = (props) => {
const { game, user, dispatch, board } = props;
const { game, user, dispatch, board, meta } = props;
const sizeFlag = `Game__board--size-${ game.boardSize }`
const renderPoints = boardSize => {

View file

@ -2,8 +2,8 @@ import React from 'react';
import './Point.scss';
const Point = (props) => {
const { posX, posY, user, game, dispatch, pointData } = props;
const turn = game.turn > 0 ? 'black' : 'white';
const { posX, posY, user, game, meta, dispatch, pointData } = props;
const turn = meta && meta.turn ? meta.turn > 0 ? 'black' : 'white' : game.turn > 0 ? 'black' : 'white';
const stone = () => {
if (pointData === 1) return 'black'

View file

@ -39,7 +39,7 @@ const Game = (props) => {
return dispatch(action);
}
roomSocketConnect();
}, [ state.active.game.open , dispatch, state.user ] )
}, [ state.active.game, dispatch, state.user ] )
return (
<div
@ -60,6 +60,7 @@ const Game = (props) => {
<Board
dispatch={dispatch}
game={state.active.game}
meta={state.meta}
record={state.active.record}
user={state.user}
board={state.board}

View file

@ -21,7 +21,7 @@ export const gamesReducer = (state, action) => {
case 'UPDATE_BOARD':
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':
return {...state, active: action.body};