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

168
Visualizações
React - BackgroundImage with data doesn't display

I'm using React and i'm trying to inject dynamically a backgroundImage from a data.json, so i'm writing my backgroundImage directly in the jsx, as inline-style, but the background don't wants to show up. I've already checked the source, and it's correct !

I'll give you a code sample and a screen of my console to show you that my path for the backgroundImage is correct !

const Card = ({ artCard }) => {
const backgroundThumbnail = artCard.images.thumbnail;
console.log(backgroundThumbnail);
return (
<React.Fragment>
  <div
    className="card"
    style={{
      backgroundImage: `url(${backgroundThumbnail})`,
      backgroundRepeat: "no-repeat",
      backgroundSize: "cover",
      backgroundPosition: "center",
      minHeight: "300px",
      minWidth: "300px",
    }}
  >
    {/* <h3>{artCard.name}</h3> */}
    {/* <h4>{artCard.artist.name}</h4> */}
  </div>
</React.Fragment>
);
};

Screenshot 👇 google console

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You forgot to add a double quote inside the bracket, try this:

backgroundImage: `url("${backgroundThumbnail}")`

Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/background-image

about 4 years ago · Santiago Trujillo Relatório

0

Alright, found the problem, my images were not on the public folder, so react won't read it !

about 4 years ago · Santiago Trujillo 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