Skip to content

Latest commit

 

History

History
42 lines (36 loc) · 2.76 KB

Sensors.md

File metadata and controls

42 lines (36 loc) · 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.