title: how to set setInterval in reactjs
body: <p>i am trying to call a function in reactjs using <code>setInterval</code> like this:</p>
  
  <pre><code>import React,{Component} from 'react';
  
  class Timer extends Component {
  
  trigger(){
     this.clock = this.setState({clock:Date.now()-this.props.date});
  }
  setInterval(this.trigger,1000);
  constructor(props){
      super(props);
  
      this.state = {
      clock:0
      };
      this.trigger = this.trigger.bind(this);
  }
  
  render(){
      this.state.clock=Math.round(this.state.clock/1000);
      return(
          &lt;div&gt;
              &lt;p&gt;You are here since&lt;/p&gt;
              &lt;span&gt;{this.state.clock}&lt;/span&gt;
              &lt;p&gt;Seconds.&lt;/p&gt;
              &lt;button onClick={this.trigger}&gt;Click me&lt;/button&gt;
         &lt;/div&gt;
     );
  }
  }
  
  export default Timer;
  </code></pre>
  
  <p>Which returns this error instead:</p>
  
  <pre><code>Syntax error: F:/reactjs1/project-6/timer/src/Timer.js: Unexpected token (8:22)
  Syntax error: F:/reactjs1/project-6/timer/src/Timer.js: Unexpected token (8:22)
  
  6 |     this.clock = this.setState({clock:Date.now()-this.props.date});
  7 |   }
  &gt;   8 |   setInterval(trigger,1000);
                          ^
  </code></pre>