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

148
Visualizações
Return the same value for every first 3 items

I'm trying to return the same value for every 3 items inside of a function. I'm doing this to align images in rows of cards by giving a certain height to each row of 3 each 3 card would have the same height than the next three will have the same etc.

  const handleHeadline = (): string => {
    const lineHeight: number = parseInt(headlineRef.current?.style?.lineHeight, 10)
    const lineBreaks = headlineRef.current?.offsetHeight / lineHeight

    if (lineBreaks === 1) {
      return '40px'
    }
    if (lineBreaks === 2) {
      return '60px'
    }
    if (lineBreaks === 3) {
      return '80px'
    }
    if (lineBreaks === 4) {
      return '100px'
    }
    return ''
  }

This function runs inside of the mapped row of cards. The maps run through up to 3 items for each row.

    {rows.slice(0, rowCount || rows.length).map((row, i) => (
        <OuterContainer key={uuidv4()}>
          <Container>
            {row.map(
              (card: OpenGraphCardProp, idx: number) =>
                (card?.headline || card?.image) && (
                  <OpenGraphCard
                    id={idx + 1 || card.id}
                    headline={card.headline}
                    image={card.image}
                    subline={card.subline}
                    name={card.name}
                    link={card.link}
                    key={`${card.id}-${uuidv4()}`}
                    linkText={card.linkText}
                    baseUrl={baseUrl}
                  />
                )
            )}
          </Container>
          {i < rows.length - 1 ? (
            <DividerContainer>
              <Divider />
            </DividerContainer>
          ) : null}
about 4 years ago · Santiago Gelvez
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