Render prop that detects if touch interactions are available or not. It's important to remember that touch detection can be fallible.
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())
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.