Skip to content

Latest commit

 

History

History
36 lines (23 loc) · 750 Bytes

WidthSensor.md

File metadata and controls

36 lines (23 loc) · 750 Bytes

<WidthSensor>

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

Example

Use it as FaCC

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

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

Or use onWidth prop

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

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

withWidth() HOC and @withWidth decorator

Works same as withSize() and @withSize.

Incldue withWidth as follows

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