Permalink
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (36 sloc) 2.76 KB

Sensors

Sensors are render pros that track some behavior and re-render on state change.

For example, the below <div> will be re-rendered every time mouse position changes.

<MouseSensor>
  {({posX, posY}) => <div />}
</MouseSensor>

libreact comes with plenty of sensors built-in.

Most sensors have also corresponding HOC and class decorator that provide the same functionality. For example, <NetworkSensor> render prop component has a corresponding withNetowrk() HOC and @withNetwork decorator.