0

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.

1
  • 1
    {()=>{this.renderUpcomingReminders()}} You aren't calling the function here, you're creating another function that calls renderUpcomingReminders.. So I think what you want is {this.renderUpcomingReminders()} Commented Jun 21, 2017 at 0:36

1 Answer 1

1

Replace {()=>{this.renderUpcomingReminders()}} with {this.renderUpcomingReminders().bind(this)}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.