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

217
Visualizações
GIF from SRC folder in React project not showing

I have a component which should display a gif from the "/src/images" folder. Unfortunately that doesn't happen. I only get my "old" value displayed. What am I doing wrong?

Danke.js site:

import Confetti from "../images/confetti.gif";

<Box sx={{ justifyContent: "center", display: "flex" }}>
  <img
    src={Confetti}
    alt="Danke"
    width={"50%"}
    style={{ borderRadius: "50%", border: "7px solid black" }}
  />
</Box>

enter image description here

Result:

enter image description here

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

0

The image file is a local asset within the app, use require to access the local asset and pass to the src attribute. Note that this is different than using a normal path string to an asset in the built public directory.

<img
  src={require("../images/confetti.gif")}
  alt="Danke"
  width={"50%"}
  style={{ borderRadius: "50%", border: "7px solid black" }}
/>

or

const Confetti = require("../images/confetti.gif");

<Box sx={{ justifyContent: "center", display: "flex" }}>
  <img
    src={Confetti}
    alt="Danke"
    width={"50%"}
    style={{ borderRadius: "50%", border: "7px solid black" }}
  />
</Box>
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