React addEventListener scroll

.esc·2022년 8월 16일
0
  const ref = useRef();

  const handleScroll = () => {
    console.log('scroll');
  };

  useEffect(() => {
    const div = ref.current;
    if (div) {
      div.addEventListener('scroll', handleScroll);
    }
  }, []);


  return <ul ref={ref}></ul>

https://coding-time.co/scroll-events-react-hooks/

profile
front-end

0개의 댓글