I'm trying to layout an n x n matrix using Reactstrap in a React component. My thought was to add a <Row>
element before the start of every row, and an </Row>
at the end of every row. But I can't get it to work with JSX, which keeps complaining Parsing error: Unexpected token, expected ","
I am passing an array of 'characters' to my component and trying to use Array.prototype.map
in my render
method to generate the JSX layout, laying out a matrix of CharacterCards
, one for each component. Imagine a set of playing cards: I simply wish to lay them out in a square.
render() {
const {props: {characters, rowSize, cardSize}} = this
const rowUnit = 12 / rowSize
const cardLayout = characters.map((character, i) => {
let isRow = (i % rowSize === 0)
let isRowFinish = ((i + 1) % rowSize === 0)
return (
{isRow && <Row>}
<Col xs='6' md={rowUnit}>
<CharacterCard key={i + Math.random()}
character={character}
cardSize={cardSize}
/>
</Col>
{isRowFinish && </Row>}
)
})
return <div>
<Container>
{cardLayout}
</Container>
</div>
}
but I get the following error
Where is the error I am clearly making? Thanks for any advice...