react-window-state
Pass updated window width and height as props on resize. Highly inspired by react-window-mixin.
Install
$ npm install react-window-state
Usage
import { withWindowState } from 'react-window-state';
const WrappedComponent = withWindowState(BaseComponent);
class App extends Component {
render() {
return <WrappedComponent />;
}
}
class BaseComponent extends Component {
render() {
// retrieve updated window, document state from props
const { win, doc } = this.props;
return (
<div>
<p>window - width: {win.width}, height: {win.height}</p>
<p>document - width: {doc.width}, height: {doc.height}</p>
</div>
);
}
}
API
withWindowState(BaseComponent, options)
BaseComponent
Required
Type: ReactComponent
options.wait
Optional
Type: number
Default: 10
The number of milliseconds to throttle invocations to.
License
MIT © C.T. Lin