class Day extends React.Component { constructor(props) { super(props); this.state = {}; } selectDate(){ var month = (this.props.month + 1).toString(); var day = this.props.date.toString(); if(month.length==1){ month = '0' + month; } if(day.length==1){ day = '0' + day; } this.props.selectDate(new Date(this.props.year + '-' + month + '-' + day)); } render() { var result; if(this.props.date==''){ result = ( {this.props.date} ) }else{ if(this.props.selectedDate.getMonth()==this.props.month && this.props.selectedDate.getDate()==this.props.date){ result = ( {this.props.date} ) }else{ result = ( this.selectDate(e)}> {this.props.date} ) } } return result; } }