我正在使用 react-table 生成表格(https://react-table.js.org/#/story/readme)。我有一个状态定义如下:
this.state = {
sampleTable:[
{author: 'Mac', books: [{title:'One', price: 20}, {title:'Two', price: 20}]},
{author: 'Rick', books: [{title:'Three', price: 20}, {title:'Four', price: 20}]}
],
sampleTableColumns:[
{Header: 'Author', accessor: 'author'},
{Header: 'Books', accessor: 'books.title'},
],
};
我正在尝试制作如下表格:
<ReactTable
className="-highlight"
data={this.state.sampleTable}
columns={this.state.sampleTableColumns}
defaultPageSize={10}
/>
但是在书籍栏中我什么也没看到。我不确定我应该如何迭代书籍数组,以便我可以在书籍列中打印书名?