Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

toggle class onscroll hook react

  const [scroll, setScroll] = useState(0)

  useEffect(() => {
    document.addEventListener("scroll", () => {
      const scrollCheck = window.scrollY < 100
      if (scrollCheck !== scroll) {
        setScroll(scrollCheck)
      }
    })
  })
Comment

PREVIOUS NEXT
Code Example
Javascript :: useeffect skip first render 
Javascript :: js random numbers 
Javascript :: how to uncheck a radio button 
Javascript :: js obj getting count of properties 
Javascript :: addeventlistener on select option 
Javascript :: ajax file upload from modal 
Javascript :: how to downgrade node version 
Javascript :: json multiple records 
Javascript :: api testing 
Javascript :: react native tab.screen hide title 
Javascript :: function palindrome javascript 
Javascript :: how to declare a variable inside a class in javascript 
Javascript :: how to debug jest test vscode 
Javascript :: firestore add document 
Javascript :: nextjs check production or development environment 
Javascript :: check if url is http or https javascript 
Javascript :: electron mass to amu 
Javascript :: js window location relative path 
Javascript :: pi in js 
Javascript :: js validate phone number 
Javascript :: how to get the timestamp in javascript 
Javascript :: electron disable menu 
Javascript :: .split is not a function 
Javascript :: using bootstrap in react 
Javascript :: npm shrinkwrap primordials 
Javascript :: js change value of every value in an object 
Javascript :: js how to sort array by string length 
Javascript :: js string times 
Javascript :: validate mobile number in javascript 
Javascript :: stop submit form jquery 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =