on-resize
ES7 Decorator & Higher-Order Component for React, which is useful on resize event.
Installation
$ npm install --save on-resize
Usage
ES7 Decorator
;; @Component { // By default, when window.onresize emits, passes following props: // `width` : window.innerWidth - this.props.offsetWidth // `height` : window.innerHeight - this.props.offsetHeight let width height children = thisprops; return <div style= width height >children</div>; } React;
If you want to customize that prop name or value, you can pass function or use select
option:
@ // OR @
Higher-Order Component
;; { let width height children = thisprops; return <div style= width height >children</div>; } Example = React;
Todo
- Add tests more
- Support Higher-Order Component
- Support other Virtual DOM libraries