title: image onclick in react
body: <p>I'm trying to add onClick function every time the user press the img.
  I tried some options that I found here at stack overflow.
  none of the above options works for me.
  I share some options that didn't work:</p>
  <pre><code>import React from &quot;react&quot;;
  
  
  export default function Movie(props) {
    
    const imageClick = () =&gt; {
      console.log('Click!!!!');
    }  
      return &lt;img alt = &quot;movieposter&quot; src = {props.link} className =&quot;d-flex justify-content-start m-3&quot; id=&quot;movie&quot; onClick={() =&gt; imageClick}/&gt;
    }
  
  </code></pre>
  <pre><code>import React from &quot;react&quot;;
  
  
  export default function Movie(props) {
    
    imageClick = () =&gt; {
      console.log('Click!!!!');
    }  
      return &lt;img alt = &quot;movieposter&quot; src = {props.link} className =&quot;d-flex justify-content-start m-3&quot; id=&quot;movie&quot; onClick={this.imageClick}/&gt;
    }
  </code></pre>
  <pre><code>import React from &quot;react&quot;;
  
  
  export default function Movie(props) {
    
    imageClick = () =&gt; {
      console.log('Click!!!!');
    }
  
    render () 
      {
      return (
      &lt;img alt = &quot;movieposter&quot; src = {props.link} className =&quot;d-flex justify-content-start m-3&quot; id=&quot;movie&quot; onClick={this.imageClick}/&gt;
      )
    }
  }
  </code></pre>