React conditionally render based on viewport size
Perhaps I am suppposed to work it with ComponentWillMount or ComponentDidMount Yes, you need to listen for resize event and update internal state on change. You can do it by adding event handler when component mounts. Try full example here. class App extends React.Component { constructor(props) { super(props); this.state = { isDesktop: false //This is …