#Volks help

1 messages · Page 1 of 1 (latest)

blazing falcon
#

Move the handleScroll inside the useEffect function. And update your code like this

  useEffect(() => {
    const handleScroll = () => {
      if (window.scrollY > 300) {
        setShowButton(true);
      } else {
        setShowButton(false);
      }
    };

    window.addEventListener('scroll', handleScroll);
    return () => window.removeEventListener('scroll', handleScroll);
  }, []);
latent notch
#

@blazing falcon thanks, it's not working for me but I'll take a closer look at what differs in our setup