I followed the instruction from this post Update style of a component onScroll in React.js to register event listener for scroll event.
I have a React component that ren
Your code looks good, so it's probably not the window itself that is scrolling. Is the table placed inside a div
or something that has overflow: auto
or overflow:scroll
? If so, the listener must be attached to the actual element that is scrolling, e.g.
document.querySelector('.table-wrapper')
.addEventListener('scroll', this.handleScroll);
If this is the case, then just adding a React onScroll handler to the wrapper in your code would be better