NewGame: show selected players in GameBoard (#28)
Reviewed-on: http://192.168.8.55:3000/HQLAx/CordaCheckers/pulls/28
This commit is contained in:
		
							parent
							
								
									76eb556d09
								
							
						
					
					
						commit
						453a45d980
					
				| @ -1,20 +1,27 @@ | |||||||
| import './GameBoard.css' | import React, { useContext } from 'react'; | ||||||
| import React from 'react' | import { useLocation, matchPath } from 'react-router-dom'; | ||||||
|  | import { GamesContext } from '../../context/games'; | ||||||
| 
 | 
 | ||||||
| import { Color, Player, Board } from '../../components/Checkers'; | import { Color, Player, Board } from '../../components/Checkers'; | ||||||
| 
 | import './GameBoard.css'; | ||||||
| //import { AppContext } from '../../context/app' |  | ||||||
| 
 | 
 | ||||||
| export default function GameBoard() { | export default function GameBoard() { | ||||||
|  |   const games = useContext(GamesContext); | ||||||
|  |   const {pathname} = useLocation(); | ||||||
| 
 | 
 | ||||||
|  |   var whiteName = ''; | ||||||
|  |   var blackName = ''; | ||||||
| 
 | 
 | ||||||
|   //const [ctx] = React.useContext(AppContext) |   if (matchPath('/games/new', pathname)) { | ||||||
|  |     whiteName = games.newGame.whitePlayer; | ||||||
|  |     blackName = games.newGame.blackPlayer; | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   return ( |   return ( | ||||||
|     <div className='GameBoard'> |     <div className='GameBoard'> | ||||||
|       <Player color={Color.white} name={/*ctx.newGame.whitePlayer*/"White player name"} /> |       <Player color={Color.white} name={whiteName} /> | ||||||
|       <Board /> |       <Board /> | ||||||
|       <Player color={Color.black} name={/*ctx.newGame.blackPlayer*/"Black player name"} /> |       <Player color={Color.black} name={blackName} /> | ||||||
|     </div> |     </div> | ||||||
|   ) |   ) | ||||||
| } | } | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user