title: Generate random number in React JS
body: <p>So, I'm trying to generate a random number in my simple app but this error comes can anyone please help me with this.</p>
  
  <blockquote>
    <p>./src/ComLifeCycle.js</p>
    
    <p>Syntax error: E:/REACT/props-states/src/ComLifeCycle.js: Unexpected
    token, expected, (31:37)</p>
    
    <blockquote>
      <p>31 |     this.setState(number: Math.random()); // problem in this line.</p>
    </blockquote>
  </blockquote>
  
  <pre><code>import React, { Component } from 'react';
  import logo from './logo.svg';
  import './ComLifeCycle.css';
  
  class ComLifeCycle extends Component {
    render() {
      return (
        &lt;div className="App"&gt;
          &lt;header className="App-header"&gt;
            &lt;img src={logo} className="App-logo" alt="logo" /&gt;
            &lt;h1 className="App-title"&gt;Welcome to React&lt;/h1&gt;
          &lt;/header&gt;
          &lt;Body /&gt;
        &lt;/div&gt;
      );
    }
  }
  
  class Body extends Component {
    constructor(props){
      super(props);
  
      this.state = {
        number: 0
      };
      this.generateRandomNumber = this.generateRandomNumber.bind(this);
    }
  
    generateRandomNumber = () =&gt; {
      console.log("clicked");
      this.setState(number: Math.random()); // **problem in this line**
    }
  
    render(){
      return(
        &lt;div&gt;
          &lt;p className="App-intro"&gt;
            To get started, edit &lt;code&gt;src/App.js&lt;/code&gt; and save to reload.
          &lt;/p&gt;
          &lt;button onClick={this.generateRandomNumber}&gt;Random number&lt;/button&gt;
          &lt;Number myNumber={this.state.number}/&gt;
        &lt;/div&gt;
      );
    }
  }
  
  class Number extends Component {
    render(){
      return(
        &lt;div&gt;
          &lt;br /&gt;
          &lt;p&gt;{this.props.myNumber}&lt;/p&gt;
        &lt;/div&gt;
      );
    }
  }
  
  export default ComLifeCycle;
  </code></pre>