Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

296
Vistas
React: rendering images before pressing the button

I've been trying to work on an image search react project where you can click and store images that you want after searching. Right now I am able to search for and show the image as buttons, but the images appear on the button only after you click it.

function Image(props) { 
  return (
  <button className = "photo" onClick = {props.onClick}>
    <img 
      width={200} height={200}
      src = {props.value} 
      alt = "" 
      onClick={myfunction()} />
  </button> ) 
}

These functions below are inside another class

handleClick(i){
    const image = this.state.image.slice();
    console.log(global.imageLinks);
    image[i] = global.imageLinks[i];
    this.setState({
      image: image,
    })
}

renderImage(i) {
    return (
        <Image 
        value = {this.state.image[i]} 
        onClick={() => this.handleClick(i)}
    />)
}

I tried deleting the onClick part in the button or moving the image section but it just causes a lot of errors. Is there any way so that the image will appear on the button as soon as it detects that the value is a link?

Many thanks!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda