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

172
Visualizações
Iterating through an array of objects in react to display a vertical scrolling item (Name & Logo)

I'm trying to create a vertical scrolling ticker/item list that displays the name and logo of each object within the array I set up.

I was able to successfully set up a scrolling ticker of names using some webkit animations on styled components. I originally had it set up as just an array though and now I'm adding logo's to each so I decided to change it to an array of objects shown below:

    export const businessNames = [

        {
            "name":"example name",
            "logo":"logo-url.com/business.jpeg"
        },
        {
            "name":"business name two",
            "logo":"https://sirv.com/logourl.jpeg"
        }
    ]

What's the easiest way to convert the following function to iterate through the objects to capture both the name of the business and display the logo as well?

<!-- language: reactjs -->
import { businessNames } from './businesses';
import { BusinessName } from './styles/index.jsx';

    function VerticalTicker(){
        const renderBusinesses = (names) => {
            let nameArray = [];
            let tickerCount = 0;
            let delay = 0;

            for(const name of names){
                nameArray.push(
                    <BusinessName tickerCount={tickerCount} delay={delay}>{name}</BusinessName>
                )
                tickerCount++;
                delay+= 0.5;
            }
            return nameArray;
        }

return(
        <>

            <div >
                    {renderBusinesses(businessNames)}
            </div>
        </>
    )
}

I've tried a few different looping iterations but my main problem is iterating the object correctly and pushing that info into the nameArray to display both the name and logo image. I feel like im close but if someone can guide me in the right direction i would appreciate it

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

To display an array of objects in jsx you can use javascripts .map() function

{businessNames &&
businessNames.map(({ name, logo }) => (
    <p>{name}</p>
    <p>{logo}</p>
))}

I dont quite understand the makeup of your BusinessName component, but its much easier to do the iterating in the jsx.

(If you want to clarify comment)

about 4 years ago · Juan Pablo Isaza Relatório
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