toggle class onscroll hook react

Solutions on MaxInterview for toggle class onscroll hook react by the best coders in the world

showing results for - "toggle class onscroll hook react"
Julia
16 May 2020
1  const [scroll, setScroll] = useState(0)
2
3  useEffect(() => {
4    document.addEventListener("scroll", () => {
5      const scrollCheck = window.scrollY < 100
6      if (scrollCheck !== scroll) {
7        setScroll(scrollCheck)
8      }
9    })
10  })