Rudson
Rudson

Reputation: 21

react arrow function map into map (map is not a function)

{order &&
  order.map((item, i) =>
   <tr key={i}>
    {item.attributes.map((itemAttr) => itemAttr)}
   </tr>
  )
}

I'm trying to build a table using the same Object, first map builds TR second map buids TD but I can't make it work, it gives me 'item.attributes.map is not a function'

Upvotes: 0

Views: 145

Answers (1)

Rudson
Rudson

Reputation: 21

Problem was attributes was an object as Mr. Harmandeep Singh Kalsi noticed. Thank you!

Resolved code:

{order &&
            order.map((item, i) =>
              <tr key={i}>
                <td>
                  {item.attributes['title']}
                </td>
                <td>
                  {item.attributes['quantity']}
                </td>
                <td>
                  {item.attributes['total_price']['formatted']}
                </td>
              </tr>
            )
          }

Upvotes: 1

Related Questions