created cart icon with number of items notification - it's still buggy
This commit is contained in:
@@ -17,7 +17,6 @@ var AddToCart = React.createClass({
|
||||
<div className="col-xs-offset-1 col-xs-1"><button className="btn btn-success" onClick={this._onIncreaseClick}>+</button></div>
|
||||
<div className="col-xs-2"><button className="btn" style={countStyle} > { this.state.item.get('count') } </button></div>
|
||||
<div className="col-xs-1"><button className="btn btn-success" onClick={this._onDecreaseClick}>-</button></div>
|
||||
<div className="col-xs-7"><button className="btn btn-warning">U korpu</button></div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
@@ -25,14 +24,12 @@ var AddToCart = React.createClass({
|
||||
// Add change listeners to stores
|
||||
componentDidMount: function() {
|
||||
CartStore.addChangeListener(this._onChange);
|
||||
|
||||
CartActions.load();
|
||||
},
|
||||
|
||||
|
||||
getInitialState: function() {
|
||||
|
||||
var itemInCart = CartStore.getStateFor(this.props.itemId);
|
||||
var itemInCart = CartStore.getStateFor(this.props.itemId);
|
||||
return { item: itemInCart }
|
||||
},
|
||||
|
||||
@@ -50,7 +47,12 @@ var AddToCart = React.createClass({
|
||||
|
||||
_onDecreaseClick: function () {
|
||||
CartActions.takeItemOut(this.props.itemId);
|
||||
},
|
||||
|
||||
componentWillUnmount: function () {
|
||||
CartStore.removeChangeListener(this._onChange);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = AddToCart;
|
||||
|
||||
Reference in New Issue
Block a user