Skip to content

Latest commit

 

History

History
43 lines (28 loc) · 1.11 KB

TouchSupportSensor.md

File metadata and controls

43 lines (28 loc) · 1.11 KB

<TouchSupportSensor>

React Universal Interface

Render prop that detects if touch interactions are available or not. It's important to remember that touch detection can be fallible.

Example

Use it as FaCC, attach to root element

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

<TouchSupportSensor>{({touchSupported}) =>
  <div>{touchSupported ? 'touch interactions available' : 'touch interactions not available'}</div>
}</TouchSupportSensor>

Use it as a plain function

import { touchSupported } from 'libreact/lib/TouchSupportSensor';

console.log(touchSupported())

Props

Prop signature

interface ITouchSupportSensorProps {
  onlyMouse?: boolean;
  onlyTouch?: boolean;
}

, where

  • onlyMouse - optional, boolean, will only render children if touch support is not detected.
  • onlyTouch - optional, boolean, will only render children if touch support is detected.