I am checking to see if the user is on a device smaller than 768px, and if they are I want to set isTop to false. I am running into a few issues. Everything looks to be okay, but I keep getting this error:
TypeError: _this2.state.isTop is not a function
What I am working with:
componentDidMount() {
this.updateWindowDimensions();
window.addEventListener('resize', this.updateWindowDimensions);
document.addEventListener('scroll', () => {
const isTop = window.scrollY < window.innerHeight - 50;
if (isTop !== this.state.isTop) {
this.setState({ isTop })
}
});
this.checkWidth = () => {
const match = window.matchMedia(`(max-width: 768px)`);
if (match) {
this.state.isTop(false);
}
};
this.checkWidth();
window.addEventListener('resize', this.checkWidth);
}
Any help would be appreciated