title: Sticky navbar with React Nextjs
body: <p>I'm trying to setup a sticky navbar with nextjs but the resulting navbar is not working like it should. Can anyone help with the code below?</p>
  <pre><code>import React, { useEffect } from 'react'
  import styles from './navbar.module.css'
  
  const Navbar = () =&gt; {
      const [scrolled, setScrolled] = React.useState(false);
  
      const handleScroll = () =&gt; {
          const offset = window.scrollY;
  
          if (offset &gt; 200) {
              setScrolled(true);
          }
          else {
              setScrolled(false);
          }
      }
      useEffect(() =&gt; {
          window.addEventListener('scroll', handleScroll)
      })
  
  
      return (
          &lt;div className={scrolled ? styles.scrolled : styles.navbar}&gt;
              &lt;ul className={styles.ul}&gt;
                  Something
              &lt;/ul&gt;
              Navbar
          &lt;/div&gt;
      )
  
  };
  
  export default Navbar;
  </code></pre>