UNPKG

react-forceify

Version:

Simple, yet powerful touch-force level detector

18 lines (17 loc) 527 B
import Forceify from 'forceify'; import React from 'react'; import ReactDOM from 'react-dom'; export default class ReactForceify extends React.Component { componentDidMount() { const { onForce, ...props } = this.props; if (this.props.onForce) { const el = ReactDOM.findDOMNode(this); this.instance = new Forceify(el, props).onForce(onForce) } else { console.error(`Please pass the «onForce» prop to the component as event handler, else it will not work`); } } render() { return this.props.children } }