I have an array of objects I wanted to display in a table. I have the following code
class Table extends React.Component {
constructor(props) {
super(props);
this.state = {
data: this.props.data
};
}
render() {
return (
<table>
{this.state.data.map(row => {
console.log(row);
<Test/>
})}
</table>
);
}
}
class Test extends React.Component {
constructor(props) {
super(props);
console.log("7");
}
render() {
return;
}
}
The console.log() in the Table prints out all my data correctly, however, the console.log() in my Test constructor never prints.
Why is the Test not being created?
My proper rows is below:
class Rows extends React.Component {
constructor(props) {
super(props);
this.state = {
data: this.props.rowData
};
console.log("2");
}
render() {
return (
<tr>
<td>{this.state.data.paymentFrom}</td>
<td>{this.state.data.paymentTo}</td>
<td>{this.state.data.paymentPeriod}</td>
<td>{this.state.data.paymentAmount}</td>
</tr>
);
}
}