title: How to write a javascript function within react?
body: <p>I am trying to set a timer to change the img src within reactbut it seems like this is not working.I saw that to write javascript we need to enclose it withing braces I did that but its still not helping. Code:-</p>
  
  <pre><code>class Default extends Component{
      render() {
      return (
         &lt;div&gt;              
            &lt;Grid.Row style={{height: '250px',margin:'-10px'}} className="adbanner"&gt; 
              &lt;input id="ad" type="image" src={ad1} style={{position:'absolute',height:'50%',width:'100%'}}&gt;&lt;/input&gt;
                {
                  setTimeout(myFunction, 3000)
                  myFunction{
                  document.getElementById("ad").src="ad2";
                  }
                }   
  
            &lt;/Grid.Row&gt;
         &lt;/div&gt;
      );
    }
  }
  export default Default;
  </code></pre>