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

164
Visualizações
Loading and rendering an image in react with a passed image url through props

I have a react component that is mean to render an image. Withing the functional component, I am passing in the images relative path from the file. I want to simple render the image in the url browser. I did read that I should be using require. When I try to render it, it shows that the image is not there and the empty image icon. I am not sure what else to do. here is my component.

import React from 'react'

export default function PropertyImage({ image }) {
  console.log(image)
  return (
    <div>
      <img src={require(image)}/>
    </div>
  )
}

I have also tried:


export default function PropertyImage({ image }) {
  console.log(image)
  return (
    <div>
      <img src={image}/>
    </div>
  )
}

This is the relative path that I have which is what image shows in the console.log:

../images/unnamed.jpeg

Here is the file structure.

File Structure

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