I have trying about not been able to figure out the reason. I have a state variable which gets updated in constructor
renderUpcomingReminders(){
const upComingReminders = _.map(this.state.upComingReminders,(reminder, key) =>{
if(!reminder.edit){
return(<Row >
<Col sm={12}>
<div className="products" >
<h4 className="content"> <span className="glyphicon glyphicon-unchecked"> </span> {typeof reminder !== 'undefined'?reminder.message: null}
<span className="badge badge-default">{typeof reminder !== 'undefined'?moment(reminder.scheduled_datetime).format('MMMM DD at hh:mm a'): '-'}</span></h4>
<div className="pull-right">
<Button bsStyle="primary" onClick={()=>{this.editReminder(key)}}>Edit</Button>
<Button bsStyle="danger" >Remove</Button>
</div>
</div>
</Col>
</Row>);
}else {
return (<Row key={key.toString()}>
<Col sm={12}>
Edit here.
</Col>
</Row>);
}
});
console.log(112);
return upComingReminders;
}
So this function is to render the reminders according to the edit flag.
<Col sm={12}><h4><a className="heading">Upcoming Reminders</a></h4></Col>
{()=>{this.renderUpcomingReminders()}}
This is how I am calling the function to render the result. Now problem is that the function is not logging the value in console .log function.
I am confused with React's iteration and conditional rendering.
{()=>{this.renderUpcomingReminders()}}You aren't calling the function here, you're creating another function that callsrenderUpcomingReminders.. So I think what you want is{this.renderUpcomingReminders()}