React component to detect window size change
$ npm install --save react-window-detect-dimensions
class DimensionDemo extends React.Component<{}> {
render() {
return (
<WindowDimensions>
{ ({ windowWidth, windowHeight }) => (
<div>
width: {windowWidth}, // get window width
height: {windowHeight} // get window height
</div>
)}
</WindowDimensions>
);
}
}
npm start
npm run gh-pages
MIT © chilijung