Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

216
Vistas
Creating dividers in every three rows from an array of cards

Grid grow example

Hello guys, I'm trying to create a Divider for every row of 3 items This is my current setup, but the issue is I'm handling only two sets of rows, and there can be an unlimited amount of rows I'm using slice to get the first two rows

The divider can't be inside a map since it needs to be placed outside the container. The divider need to be placed between every two rows. It currently only handles two rows, but it needs to take more than two rows.

Example codepen https://codesandbox.io/s/summer-firefly-xzymsp?file=/src/App.tsx

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You could try to prepare your OpenGraphGridDate and arrange it in rows. this way it is easy to use two nested map function.

const OpenGraphGridModule = () => {
  const rows = OpenGraphGridData.reduce((rows,el)=> {
    if(rows[rows.length-1].length >= 3){
      rows.push([]);
    }
    rows[rows.length-1].push(el);
    return rows;
  },[[]]);

  return (
    <>
      {rows.map((row,i) => 
        (
          <>
            <Container>
            {row.map(el => (
              <Card />
            ))}
            </Container>
            {(i < rows.length-1) ? (
              <DividerContainer>
                <Divider />
              </DividerContainer>
            ) : null}
            
          </>
        )
      )}
    </>
  )
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda