I'm currently encountering a problem when i'm calling a for loop in a functional/class component in React. For exemple if I want to create a simple function to render multiple td tr in a table React is going to infinite call the function.
class ReserveView extends Component {
createTable() {
const table = []
for (let i = 0; i < 3; i + 1) {
const children = []
for (let j = 0; j < 5; j + 1) {
children.push(<td>{`Column ${j + 1}`}</td>)
}
table.push(<tr>{children}</tr>)
}
return table
}
render() {
return (
<div>
<table>
{this.createTable()}
</table>
</div>
)
}
If i console.log(j) the console will output this
I'm using React for a year now and it's the first time I'm having this issue. Thanks a lot for your help