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

322
Visualizações
React Js Inline style not working on loop condition

i am getting problem when doing loop in react JS. I want to make a different background for each item according to the data I have created. I tried to use the inline style to make it dynamic, but it doesn't work. Any suggestions or solutions regarding this?

        {
            main.map((item, index) => (
                <a key={index} href='#' className="col-12 main-item-img" style={{backgroundImage: `url(${item.bg})`, backgroundPosition: 'center', backgroundSize: 'cover'}}>
                    <h2>{item.name}</h2>
                    <img src={item.logo} className='item-img' alt={item.region} srcSet="" />
                    <p>{item.desc}</p>
                    <div className="overlay"></div>
                </a>
            ))
        }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Solved! The problem is not in the loop but in the slick slider that I use. In the description I didn't explain that I was using the slick slider because I thought the problem was in the loop.

i just need to add before . The result is like this

    <Slider {...carouselSettings} style={{ width: '100%' }}>
        {
            main.map((item, index) => (
                <div> //add this element
                    <a key={index} href='#' className="col-12 main-item-img" style={{backgroundImage: `url(${item.bg})`, backgroundPosition: 'center', backgroundSize: 'cover'}}>
                        <h2>{item.name}</h2>
                        <img src={item.logo} className='item-img' alt={item.region} srcSet="" />
                        <p>{item.desc}</p>
                        <div className="overlay"></div>
                    </a>
                </div>
            ))
        }
    </Slider>
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