I'm writing a Product component in react.js, and I'd like to increase the inCartCount value of actual product when the item is clicked.
import React, { PropTypes } from 'react';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './Product.css';
var NumberFormat = require('react-number-format');
class Product extends React.Component {
addToCart(product) {
console.log(product.inCartCount);
product.inCartCount++;
}
render() {
const product = this.props.data;
product.inCartCount = product.inCartCount || 0;
return (
<div onClick={this.addToCart.bind(this, product)}>
<h3>{product.name}</h3>
<NumberFormat value={product.price} displayType={'text'} thousandSeparator={true} suffix={' Ft'}/>
<span>{product.inCartCount}</span>
</div>
);
}
}
export default withStyles(s)(Product);
in console.log the value is increasing, but it is not rendered to DOM, I always see 0 as inCartCount value in the browser.