Im used to do this kind of code using ejs, is there an equivalent way of doing this using react?
What Im trying:
I need to create a new to each aux.Complements elements, the problem is that I cant do {return complement.title} inside html elements
JavaScript
x
10
10
1
{item.ComplementCategories.map(aux => {
2
aux.Complements.map(complement => {
3
<tr>
4
<td>
5
{complement.title}
6
</td>
7
</tr>
8
})
9
})}
10
What I get:
Expected an assignment or function call and instead saw an expression no-unused-expressions
Advertisement
Answer
Based on @DennisVash comment I came up with the following solution
JavaScript
1
23
23
1
item.ComplementCategories.map(aux => {
2
return aux.Complements.map(complement => {
3
return <tr className="tableList--complements">
4
<td className="text-left">
5
{complement.title}
6
</td>
7
<td className="text-center"> - </td>
8
<td className="text-right">
9
R$ {complement.price_un}
10
</td>
11
<td className="text-center">
12
{complement.quantity}X
13
</td>
14
<td className="text-right">
15
-
16
</td>
17
<td className="text-right">
18
-
19
</td>
20
</tr>
21
})
22
})
23
Returned a html element and accessing the data through {}
Can also Help