1

So I'm trying to print some HTML code depending on the IF statement.

but I'm getting "undefined[object Object][object Object][object Object]"

 public render(): React.ReactElement<ISPWebPartProps> {
     return (
     <div className={styles.yearEvents}>
    <div className={styles.container}>
      <div className={styles["year-print"]}>
        <div className={styles["year-print-month"]}>
          <div className={styles.container}>
            {this.state.renderMonth}
          </div>
        </div>
      </div>
    </div>
  </div>

 );
}


private _getListItemssAsync(items: IListItems[]) {
let element;
items.forEach((item: IListItem) => {
  if (month == item.CurrentMonth) {
    element += <div className="year-print">
      <ul><li className="year-print-month"><strong>
       {Month}
   </strong>
      </li>
      </ul>
    </div>;
  }
this.setState({ 'renderMonth': element });
};

Any ideas ?

  • Assign element variable using backticks like element += ``content goes here``. And I don't see what is the value of {Month}` – Ashik Paul M Jul 18 '18 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.