How to set variable in .map() in ReactJS

render() {

this.yearTransactionNum=0;

return (

....
{this.props.transactions.length > 0 && this.props.transactions.map((transaction,index) => {

if ( this.props.invoiceYear == 'All' || transaction.date_formated.indexOf(this.props.invoiceYear) != -1 ) {

this.yearTransactionNum++;

return (

<React.Fragment>

.....

) else {

...

}
{(this.props.transactions.length > 0 && this.yearTransactionNum == 0) &&

<div className='text-center col-md-12 p-5'><i class="fa fa-exclamation-triangle mr-2"aria-hidden="true"></i>No Transaction for Year {this.props.invoiceYear}</div>

}

Leave a Reply

Your email address will not be published. Required fields are marked *