Answer the question
In order to leave comments, you need to log in
Rendering properties of array objects?
When the button is clicked, [{}, {}, {}] are unloaded. Each object has properties.
const [list, listRender] = useState(<tr></tr>);
------------------------------------------------
const data = await request('api/search/test', 'POST', { ...form });
listRender(data.map((item, index) =>
<td key={index}>{item}</td>
));
<tbody>
<tr>{list}</tr>
</tbody>
Answer the question
In order to leave comments, you need to log in
listRender(data.map((item, index) =>
<tr key={index}>
<td>{item.date}</td>
<td>{item.studID}</td>
<td>{item.fullName}</td>
<td>{item.facility}</td>
<td>{item.typeFacility}</td>
<td>{item.time}</td>
</tr>
));
<tbody>
{list}
</tbody>
If I'm not mistaken, and I often am. You need it like this:
listRender(data.map((item, index) =>
<td key={index}>{item}</td>
));
// Не занимался подобными извращениями - map возвращает новый массив, forEach просто перебирает, советую подтянуть в этом плане
<tr>{list.map(el => el)}</tr>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question