Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

163
Visualizações
Generate components React inside return using iteration

Hi I'm trying to generate rows for a component form inside a React return, the condition for generate the rows is: Generate a row with max two elements locatable(property).

The array:

const properties = [
    {
      title: 'Codigo',
      dataIndex: 'code',
      locatable: true
    },
    {
      title: 'Nombre',
      dataIndex: 'name',
      locatable: true
    },
    {
      title: 'Precio',
      dataIndex: 'price',
      locatable: true
    },
    {
      title: 'Fabricante',
      dataIndex: 'maker',
      locatable: true
    }
]

I know, I have errors in the way I'm triying to generate rows inside the Return, but I don't know how do it.

return(
    <>           
            <Form layout="vertical" hideRequiredMark>
                {
                    var propertiesLocatables = []
                    properties.forEach(element => {
                        if(element.locatable)
                            propertiesLocatables.push(element)
                    });
                    
                    var size = Object.keys(propertiesLocatables).length
                    //for each two properties make a row with max two elements
                    for(let i=0; i < size; i+2){
                        <Row gutter={16}>
                            <Col span={12}>
                                <Form.Item name={propertiesLocatables[i].dataIndex} label={propertiesLocatables[i].title}
                                    rules={[{ required: true, message: 'Please enter value' }]}>
                                    <Input placeholder="Please enter value" />
                                </Form.Item>
                            </Col> 
                            if(propertiesLocatables[i+1].dataIndex!==undefined)
                            {
                                <Col span={12}>
                                    <Form.Item name={propertiesLocatables[i+1].dataIndex} label={propertiesLocatables[i+1].title}
                                        rules={[{ required: true, message: 'Please enter value' }]}>
                                        <Input placeholder="Please enter value" />
                                    </Form.Item>
                                </Col>     
                            }       
                        </Row>
                    }
                }
            </Form>
    </>
)
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda