У меня есть список объектов, называемых элементами. Я хочу, чтобы каждый объект в списке был строкой в таблице. Однако строки не отображаются. Я использую машинописный текст с react- bootstrap. Мне интересно, почему это произошло и как это исправить. Спасибо!
Template.tsx
export default function Templates() {
const items = [
{
"name": "Item 1",
"alt": "First",
"description": "This is the first item"
},
{
"name": "Item 2",
"alt": "Second",
"description": "This is the second item"
},
{
"name": "Item 3",
"alt": "Third",
"description": "-"
}
]
return (
<>
<MyTable items={items}>MyTable</MyTable>
</>
)
}
MyTable.tsx
import React from 'react'
import { Table, Button } from 'react-bootstrap'
type TableProps = {
items: {
name: string,
alt: string,
description: string
}[]
}
const MyTable: React.FunctionComponent<TableProps> = ({
items
}) => {
return (
<>
<Table striped bordered hover variant="dark">
<thead>
<tr>
<th>Name</th>
<th>Alt</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{items.map(item => {
<tr>
<td>{item.name}</td>
<td>{item.alt}</td>
<td>{item.description}</td>
</tr>
})}
</tbody>
</Table>
</>
)
};
export default MyTable;
Сейчас выполняется рендеринг только thead.