I want to create nested elements in react js but following does not seem to work.
var allSeats = [];
for( let i = 0 ; i<5 ; i++ ) {
allSeats.push( <div className="each-row"> );
for( let j=0; j<2 ; j++ ) {
allSeats.push( <div className="each-seat">hei</div> );
}
allSeats.push( </div> );
}
return (
<div className="theater">
{allSeats}
</div>
);
What's wrong with the above code?
allSeats.push( </div> );this is not a valid JSX element. It always needs an opening and closing tag. You will have to find another approach for this.