I have a Navigation component here that toggles a class onClick
import React from "react";
//COMPONENTS
import Navlinks from './Navlinks';
class Navigation extends React.Component {
constructor(props) {
super(props);
this.state = {addClass: false}
}
toggle() {
setTimeout(() => {
this.setState({addClass: !this.state.addClass});
}, 200);
}
render() {
let navClass = ["nav"];
if(this.state.addClass) {
navClass.push('open');
}
return(
<div className={navClass.join(' ')} onClick={this.toggle.bind(this)}>
<div className="icon"></div>
<Navlinks onClick={this.props.onClick}/>
</div>
);
}
}
export default Navigation;
Is there a way that I can somehow disable the onClick event when the device viewport is larger than a certain size?