title: How can i make a simple counter in React without using state
body: <p>I'm trying to make a simple app that counts the number of times the button has been clicked. I read this is a good first question in JS interviews.
  &quot;Ask the candidate to build a click counter using any popular framework (React preferred in 2020). This ridiculously simple app has one job: keep track of how many times the user has clicked the button during the current session. No storage. No network I/O. Just count clicks. It is intentionally ridiculously simple&quot;
  My first instinct would be to use hooks, but the question wants the programmer to do it without using storage which I believe includes using state.</p>
  <pre><code>import React from 'react';
  import './App.css';
  
  function App() {
  
   let count=0;
  
   const add=()=&gt;{
      debugger;
      count++;
    }
  
    return (
        &lt;header className=&quot;App-header&quot;&gt;
        &lt;button onClick={()=&gt;add()}&gt;click me&lt;/button&gt;
        {count}
        &lt;/header&gt;
    );
  }
  
  export default App;
  </code></pre>
  <p>Here is what I tried. Using debugger I can see count does go up but the changes aren't showing on the page. Any advice would be appreciated.</p>