react.js every nth item add opening tag or closing tag

后端 未结 2 1201
深忆病人
深忆病人 2021-01-02 09:22

I\'m having trouble with this logic since react/jsx does not allow for non closing tags to be added to an array/child component. For example with bootstrap css I want to add

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-02 09:47

    I actually just used arrays and react handled fine the rendering.

    render() {
        let rows = [],
            cols = []
        let index = 0
        const totalCols = 20;
    
        for (index; index < totalCols; index++) {
            cols.push(
    ) if ((index + 1) % 4 == 0) { rows.push(
    {cols}
    ) cols = [] } } return (
    {rows}
    ) }

提交回复
热议问题