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

138
Views
React parse string to asset reference

I have a system where I need to dynamically select a flag asset, but having trouble getting the code to get the reference instead of just use it as a flat string. I thought this would work:

import flagEN from '../assets/images/flags/en.svg';
const itemFlag = 'flagEN';
<img src={`${itemFlag}`} />

I want it to use the reference to the svg, but it just keeps giving me the string

<img src="flagEN">

instead of the imported path.

If I hard code it to

<img src={flagEN} />

it works, it's just something with it parsing the string into the reference. Any ideas please?

about 4 years ago · Juan Pablo Isaza
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!