title: How to add Event in React Functional Component
body: <p>I have a question about React functional components, specifically about functions in functional components. For instance:</p>
  
  <pre><code>import React, { useEffect } from 'react';
  
  const Component = (props) =&gt; {  
    useEffect(() =&gt; {
      window.addEventListener('scroll', handleScroll);
    });
    useEffect(() =&gt; {
      return () =&gt; {
        window.removeEventListener('scroll', handleScroll);
      };
    }, []);
  
    function handleScroll() {
      let scrollTop = window.scrollY;
    }
  
  
    return ()
  }
  </code></pre>