Created
April 20, 2016 10:57
-
-
Save MarcusHurney/807537e2d9d31c31ea4d5abf3ffdb338 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 React, { Component } from 'react'; | |
import { connect } from 'react-redux'; | |
var Checkout = React.createClass({ | |
render: function() { | |
return ( | |
<div onClick={this.handleClick}> | |
<h1>{this.props.cart.length}</h1> | |
</div> | |
); | |
}, | |
handleClick: function() { | |
console.log(this.props.cart.length); //Logs the length of the cart in the global state | |
//This number in the console updates properly, but the h1 tag is always 0 | |
} | |
}); | |
function mapStateToProps(state) { | |
return { cart: state.cart.currentCart }; | |
} | |
export default connect(mapStateToProps, null)(Checkout); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment