I am not very familiar with JavaScript, but have to implement a table in ReactJS for my current project. At the part bellow I get an error: map is not defined. I have done some Error-Research but could not find an satisfying answer here or on Google.
render() {
const { hits } = this.props
return (
<div style={{width: '100%', boxSizing: 'border-box', padding: 8}}>
<table className="sk-table sk-table-striped" style={{width: '100%', boxSizing: 'border-box'}}>
<thead>
<tr>
<th>Title</th>
<th>Author</th>
<th>Keywords</th>
</tr>
</thead>
<tbody>
{map(hits, hit => (
<tr key={hit._id}>
<td>{hit._source.title}</td>
<td>{hit._source.year}</td>
<td>{hit._source.imdbRating}</td>
</tr>
))}
</tbody>
</table>
</div>
)
}
Could someone point me in the right direction?
You have to use the map function on the hits const you create at the top. Like this: