How can I get image value and implement on any another div in react?

Actually I have multiple images so now I need to display clicked image on another box how can I do that in react?

My Code:-

    const imageClick = () =>{
      console.log(this.state.value);
    }


 <img src="images/1.png" onClick={()=>imageClick()} />
 <img src="images/2.png" onClick={()=>imageClick()} />
 <img src="images/3.png" onClick={()=>imageClick()} />
 <img src="images/4.png" onClick={()=>imageClick()} />

 <div className="newDiv"></div>

Not able to understand what is better way to do this?

7 thoughts on “How can I get image value and implement on any another div in react?”

Leave a Comment