I am developing a web app with React and need to detect when the screen size has entered the mobile break-point in order to change the state. Specifically I need my sidenav to b
hey I just published a npm package for this issue. Check it out https://www.npmjs.com/package/react-getscreen
import React, { Component } from 'react';
import {withGetScreen} from 'react-getscreen'
class Test extends Component {
render() {
if (this.props.isMobile()) return Mobile;
if (this.props.isTablet()) return Tablet;
return Desktop;
}
}
export default withGetScreen(Test);
//or you may set your own breakpoints by providing an options object
const options = {mobileLimit: 500, tabletLimit: 800}
export default withGetScreen(Test, options);