This should be an easy one for you React monsters. :) I have the condition written but I can\'t figure out how to handle the viewport size in my constructor for the condition to
class My Class extends React.Component {
constructor(props) {
super(props);
this.state = {
isDesktop: window.innerHeight > 1450,
};
}
render() {
const isDesktop = this.state.isDesktop;
return (
{isDesktop ? (
I show on 1451px or higher
) : (
I show on 1450px or lower
)}
);
}}
Here more info Get viewport/window height in ReactJS