Fetching contributors…
Cannot retrieve contributors at this time
42 lines (26 sloc) 774 Bytes


FaCC that re-renders on window size change.


import {WindowSizeSensor} from 'libreact/lib/WindowSizeSensor';

<WindowSizeSensor>{({width, height}) =>
  `width: ${width}, height: ${height}`

You can use it without children.

<WindowSizeSensor onChange={({width, height}) => console.log(width, height)} />

withWindowSize() HOC

HOC that merges windowSize prop into enhanced component's props.

import {withWindowSize} from 'libreact/lib/WindowSizeSensor';

@withWindowSize decorator

React stateful component decorator that adds windowSize prop.

import {withWindowSize} from 'libreact/lib/WindowSizeSensor';

class MyComp extends Component {