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


FaCC that re-renders on window width change.


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

<WindowWidthSensor>{({width}) =>
  `width: ${width}`

You can use it without children.

<WindowWidthSensor onWidth={({width}) => console.log(width)} />

withWindowWidth() HOC

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

import {withWindowWidth} from 'libreact/lib/WindowWidthSensor';

@withWindowWidth decorator

React stateful component decorator that adds windowWidth prop.

import {withWindowWidth} from 'libreact/lib/WindowWidthSensor';

class MyComp extends Component {