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

244
Visualizações
How to call specific image after importing all images from a folder in ReactJS?

I want to import all icons from an icon folder and then find the specific icon and display it on the screen. I have imported all the icons with the below code:

const images = this.importAll(require.context('./icons', false, /\.(png|jpe?g|svg)$/));
console.log(images);

importAll(r) {
  return r.keys().map(r);
}

Below is the screenshot of the console log [imported all images][1]

Now If I want to find a specific icon so how should I find it the name of the image file is not clear as highlighted in the screenshot.

const found = images.find(element => element = 'r04d.png');
console.log(found)

the above code output is shown below:

[output of found][2]

the name of the image file is not clear, how should I refer to this file and use it when required, please advise. [1]: https://i.stack.imgur.com/qc1ff.png [2]: https://i.stack.imgur.com/hbZbt.png

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