A
A
Alexander2021-06-20 12:40:25
React
Alexander, 2021-06-20 12:40:25

How to make a fixed header when scrolling in React?

Hello, please tell me how to make an animated appearance of a fixed header in react when scrolling, I will be grateful for your help
. Will this approach be used correctly?

React.useEffect(() => {
    window.addEventListener('scroll', function () {
      if (window.pageYOffset > 0) {
        console.log('open')
      } else {
        console.log('hide')
      }
    })
  }, [])

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question