A higher-order component that can be used to passing the window dimensions into your component as props.
npm i --save react-hoc-dimensions
import React from 'react';
import windowDimensions from 'react-hoc-dimensions';
class Page extends Component {
render() {
return (
<div className="page">
{this.props.windowWidth < 575
? <div> Mobile content </div>
: <div> Tablet or desktop content </div>
}
</div>
);
}
}
export default windowDimensions(Page);
Pull requests are welcome. You can check that your changes correspond to the code style by running the lint
command:
npm run lint