How to do without the state?

to determine the scroll (up/ down) use a function that hangs on the event 'scroll'.
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 to check the scrolling is not use in doing the job with state?
getScrollTop() - cross-browser function for determining the number of pixels prorolling
June 8th 19 at 16:47
1 answer
June 8th 19 at 16:49
if you don't need PreRender component, you can simply inside the component class to create a static variable and save

Find more questions by tags React