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

320
Vistas
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 Respuestas
Responde la pregunta

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 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