hiteshchoudhary/React-application

bug in a course-purchase react app

Closed this issue · 0 comments

**there is bug in course-purcahse app
in coursesales.js there is bug css was not aaplying

code :**

`
import React, { Component } from 'react';

class Coursesales extends Component {
sumPrice(price){
this.setState({total: this.state.total + price});
}
constructor(props){
super(props);

  this.state = {
		total: 0
	};
	this.sumPrice = this.sumPrice.bind(this);
}

render(){
console.log(this.props.items);
var courses= this.props.items.map((item, i)=>{
return
});

return(
  <div>
			<h1>You can buy courses : </h1>
			<div id="courses">
				{courses}
				<p id="total">Total: <b>{this.state.total}</b></p>
			</div>

  </div>
);

}
}

class Course extends Component {
clicker(){
var active = !this.state.active;
this.setState({active:active});
this.props.sumPrice(active ? this.props.price : -this.props.price);
}
constructor(props){
super(props);

  this.state = {
		active: false
	};
	this.clicker= this.clicker.bind(this);
}

render(){
return(


<p className={this.state.active ? 'active' : ''} onClick={this.clicker} >{this.props.name} {this.props.price}

  </div>
);

}
}

export default Coursesales;
`