react-native-shake
v6.8.1
Published
React Native shake event detector
Readme
React Native Shake Event Detector
If you like this, please consider...
Thank you!

With this library, you can add shake event detector on your React Native app. Because react-native-shake-event is not in active development anymore, I decided to created this.
It should work best on real devices
Installation
npm install react-native-shakeor
yarn add react-native-shakeLinking the native modules
Automatic:
From React Native 0.60, you don't have to manually link libraries anymore. Just
cd ios
pod updateand you're good to go.
Manual (iOS):
Follow this guide
Usage
For 5.x.x and higher:
import React from 'react';
export const MyComponent = () => {
React.useEffect(() => {
const subscription = RNShake.addListener(() => {
// Your code here...
});
return () => {
// Your code here...
subscription.remove();
};
}, []);
};and for older versions:
import RNShake from 'react-native-shake';
// For v3.x.x and below:
class MyComponent extends React.Component {
componentDidMount() {
RNShake.addEventListener('ShakeEvent', () => {
// Your code...
});
}
componentWillUnmount() {
RNShake.removeEventListener('ShakeEvent');
}
}
// For v4.x.x onwards:
class MyComponent extends React.Component {
componentDidMount() {
RNShake.addListener(() => {
// Your code...
});
}
componentWillUnmount() {
RNShake.removeListener();
}
}