Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

215
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!