title: Passing a number to a function in react js
body: <p>I want to pass a number to the function.I follow same way to pass both string and integer values. I can pass the string value. But I can't pass the integer value in that way. </p>
  
  <p>This is my lesson2.js file</p>
  
  <pre><code>import React from 'react'
  
  class lesson2 extends React.Component{
  
      constructor(props){
          super(props);
          this.state = {counter:1}
      }
  
      add(){
          this.setState(function(state,props){
              return{
                  counter: state.counter + props.increment
              };
          })
      }
  
      render(){
          return(
          &lt;div&gt;
              Counter : {this.state.counter}&lt;/div&gt;
          );
      }
  }
  
  export default lesson2
  </code></pre>
  
  <p>This is my App.js</p>
  
  <pre><code>import React from 'react';
  import './App.css';
  import Variable from './Components/variable_dec'
  import Lesson2 from './Components/lesson2'
  
  function App() {
    return (
      &lt;div className="App"&gt;
  
          &lt;p&gt;
            &lt;Variable name='D' /&gt;
            &lt;Lesson2 increment={10}/&gt;
          &lt;/p&gt;
  
      &lt;/div&gt;
    );
  }
  
  export default App;
  </code></pre>
  
  <p>This is my output. But in my correct output should be <strong>Counter : 11</strong>. The problem is that the increment value doesn't add to the counter. So hope your help to solve my problem.</p>
  
  <p><a href="https://i.stack.imgur.com/Z4Pqx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z4Pqx.png" alt="enter image description here"></a></p>