Add the shake event on your React Native mobile app, giving to users improved usability. Enjoy!
$ npm install react-native-shake-event --save
react-native link react-native-shake-event
- Add the
ios/RNShakeEvent.xcodeproj
file to your Xcode project Demo; - Add the
Products/libRNShakeEvent.a
file to Build Phases Demo.
This step is described here: Linking Libraries.
import RNShakeEvent from 'react-native-shake-event';
class App extends React.Component {
componentDidMount() {
RNShakeEvent.onEnded(() => {
console.debug('Device shaked.');
});
}
componentWillUnmount() {
RNShakeEvent.remove();
}
}
Start listening the shake event and handle a callback function "on began".
Start listening the shake event and handle a callback function "on ended".
Stop to listening the shake event, recommended to prevent memory leak.
- On debug mode this event also handle the DevMenu.
- Submit here.
MIT