size-decorator

react size decorator, adds width and height props to component

Usage no npm install needed!

<script type="module">
  import sizeDecorator from 'https://cdn.skypack.dev/size-decorator';
</script>

README

react size decorator,

adds width and height props to component (also recalculates this props on resize)

install

npm install --save size-decorator

usage

import size from 'size-decorator';
@size()
export default class MySuperComponent extends Component {
  constructor(props) {
    super(props);
  }

  render() {
    console.log(this.props.width, this.props.height)
    return (<div style={{width: 100, height: 100}}>HELLO</div>);
  }
}

or if you want width and height parameters on server

@size({width: 100, height: 200})