Fetching contributors…
Cannot retrieve contributors at this time
37 lines (23 sloc) 750 Bytes


FaCC that works similar to <SizeSensor> but re-renders only on width change.


Use it as FaCC

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

<WidthSensor>{({width, height}) =>
  `WIDTH: ${width}, HEIGHT: ${height}`

Or use onWidth prop

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

<SizeSensor onWidth={({width, height}) => console.log(width, height)}>
  Resize me!

withWidth() HOC and @withWidth decorator

Works same as withSize() and @withSize.

Incldue withWidth as follows

import {withWidth} from 'libreact/lib/WidthSensor';