简体   繁体   中英

React map is not rendering items

React is not rendering items on a map function.

<Tab eventKey="All" title="All">
  {this.state.todoData && this.state.todoData.length ? (
    this.state.todoData.map((item, index) => {
      return <span key={item.todoId}>{item.todoTitle}</span>;
    })
  ) : (
    <span>No item found</span>
  )}
</Tab>

Render function is not rendering items or No Item found.

What I am doing wrong here?

You are probably keeping objects in todoData that are blank or do not match the format you expected. Must be [{todoId: "id", todoTitle: "title"}] . I think the example here will help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM