I am passing an array of objects as a prop to my Table component, it is supposed to turn every item in the array to a row in a table. But it is not outputting anything...
I have used console.log to successfully look into each item within the array. This is my code:
import React from 'react';
export default class Table extends React.Component {
getTableRow(x) {
console.log(x);
return ( <tr>
<td>{x.prop1}</td>
<td>{x.prop2}</td>
<td>{x.prop3}</td>
</tr>);
}
resolveInput() {
//expecting array
const array = this.props.lastFiveList;
//array.map(x => console.log(x));
array.map(x => this.getTableRow(x));
}
render() {
return (
<table>
{this.resolveInput()}
</table>
);
}
}
I have also tried to bind both functions (same result) and place what getTableRow is supposed to return into a variable and then returned the variable instead of the multiline return(); statement. Furthermore, I tried using forEach instead of map.