I have my component defined in moviesTable.jsx <TableBody data = {this.props.movies} />
and in tableBody.jsx I use the map function nesting it, that is, I use map twice but I don't know why it says undefined, I don't see that my code is wrong, I already looked in other forums and they said I should define it with this.props, but I do have it defined, I don't think it's because I use it twice since I have a table so I don't know what is really wrong, the error marks line 21 where the first map begins .
import React, { Component } from 'react';
import _ from 'lodash';
class TableBody extends Component {
renderCell = (item, column) => {
if(column.content) return column.content(item);
return _.get(item, column.path);
}
createKey = (item, column) => {
return item._id + (column.path || column.key);
}
render() {
const { data, columns } = this.props;
return (
<tbody>
{data.map(item => (
<tr key = {item._id}>
{columns.map(column => <td key = {this.createKey(item, column)}>{this.renderCell(item, column)}</td>)}
</tr>))}
</tbody>
);
}
}
export default TableBody;
It is true that I was not defining the columns
<TableBody data = {this.props.movies} columns = {this.columns} />
, this works for me!!