How to do without the state in react js application?

时间:2018-02-01 18:40:27

标签: javascript reactjs

To determine the scrolling (up / down) I use the function that hangs on the 'scroll' event.

scrollUpDown() {
    if (this.state.lastScrollPos < getScrollTop() ) {
      this.setState({lastScrollPos: getScrollTop()});
      console.log('down')
    }
    else if (this.state.lastScrollPos > getScrollTop() ) {
      this.setState({lastScrollPos: getScrollTop()});
      console.log('up')
    }
  }

How can I check scrolling without using the work with state?

0 个答案:

没有答案