Created
October 11, 2018 17:20
-
-
Save barraponto/c02871714a87f796b3bc93683032577e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { connect } from 'react-redux'; | |
const Score = ({ score }) => (<div className="game-score"> {score} </div>); | |
const mapStateToProps = (state) => ({ score: state.game.score }); | |
export default connect(mapStateToProps)(Score) | |
/*******************************/ | |
import { connect } from 'react-redux'; | |
const shoot = () => ({type: 'SHOOT', weapon: 'laser'}); | |
const ShootButton = ({ shoot }) => ( | |
<button className="game-controls-fire" onClick={ shoot }> | |
Fire | |
</button> | |
); | |
const mapStateToProps = () => ({}); | |
const mapDispatchToProps = (dispatch) => ({ shoot: (e) => dispatch(shoot()) }); | |
export default connect(mapStateToProps, mapDispatchToProps)(ShootButton) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment