forked from Github/uno-online
Initialized Redux store, created reducer function and Game component
This commit is contained in:
@@ -1,12 +1,40 @@
|
||||
import React from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
|
||||
const Game = () => {
|
||||
const Game = (props) => {
|
||||
return (
|
||||
<div>
|
||||
<h1>Game</h1>
|
||||
|
||||
<div className='player1Deck'>
|
||||
{props.player1Deck.map((item) => {
|
||||
return <h6>{item}</h6>
|
||||
})}
|
||||
</div>
|
||||
<hr />
|
||||
<div>
|
||||
<h1>Current Card: {props.playedCardsPile[0]}</h1>
|
||||
</div>
|
||||
<hr />
|
||||
<div className='player2Deck'>
|
||||
{props.player2Deck.map((item) => {
|
||||
return <h6>{item}</h6>
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Game
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
gameOver: state.gameOver,
|
||||
turn: state.turn,
|
||||
player1Deck: state.player1Deck,
|
||||
player2Deck: state.player2Deck,
|
||||
currentColor: state.currentColor,
|
||||
currentNumber: state.currentNumber,
|
||||
playedCardsPile: state.playedCardsPile,
|
||||
drawCardPile: state.drawCardPile
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps)(Game)
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
import React from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { START_GAME } from '../store/actions'
|
||||
import { connect } from 'react-redux'
|
||||
|
||||
const Homepage = () => {
|
||||
const Homepage = (props) => {
|
||||
return (
|
||||
<div>
|
||||
<h1>Homepage</h1>
|
||||
<Link to='/play'><button onClick={props.onStartGame}>START GAME</button></Link>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Homepage
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
onStartGame: () => dispatch({type: START_GAME})
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(null, mapDispatchToProps)(Homepage)
|
||||
|
||||
Reference in New Issue
Block a user