title: Callback function on button onClick in React Functional Component
body: <p>I have two examples of calling onRemove method on button click in jsx . However although there is no compilation error , the example 2 doesnt render anything on screen which means basically it is wrong.</p>
  <p>What is wrong with the example 2 and why do we need to pass another anonymous function and instead not just call {onRemove(item.id)} on button click?</p>
  <p><strong>eg1:</strong></p>
  <pre><code>function onRemove(id) {
      //
      }
      
      &lt;button type=&quot;button&quot; onClick={() =&gt; onRemove(item.id)}&gt;
  </code></pre>
  <p><strong>eg2:</strong></p>
  <pre><code>    function onRemove(id) {
      //
      }
      
      &lt;button type=&quot;button&quot; onClick={onRemove(item.id)}&gt;
  </code></pre>
  <p><strong>Edit</strong>:
  Similarly onChange works like eg2 above.</p>
  <pre><code>const handleChange = (search) =&gt; {
      //
    }; 
  &lt;input
          id=&quot;search&quot;
          type=&quot;text&quot;
          onChange={handleChange}/&gt;
  </code></pre>