I'm making a personal website in react, and I wanted to do some tricks with scrolling, but ya know how it goes, getting stuck on step one. All I have in my react is
class App extends Component {
makeTextLarger(e) {
console.log(e)
console.log("scrolling")
}
componentDidMount() {
const list = ReactDOM.findDOMNode(this.refs.test)
console.log(list)
list.addEventListener('scroll', this.makeTextLarger);
}
componentWillUnmount() {
const list = ReactDOM.findDOMNode(this.refs.test)
list.removeEventListener('scroll', this.makeTextLarger);
}
render() {
var style = {
height: '10000px',
fontSize: 200,
background: 'blue'
};
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title"</h1>
</header>
<p className="App-intro">
text to be made bigger at some point
</p>
<div ref="test" style={style}>
Pls
</div>
</div>
);
}
}
In which nothing fires as I scroll. If I instead look at use window instead of the specific div, it works. When I console.log the list, it does indeed return an html object, so Im not sure why my binding is working selectively. Any thoughts?