React component to detect window size change
$ npm install --save react-window-detect-dimensionsclass 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-pagesMIT © chilijung