Wondering what’s next for npm?Check out our public roadmap! »

    react-native-shake
    TypeScript icon, indicating that this package has built-in type declarations

    4.0.2 • Public • Published

    React Native Shake Event Detector

    Latest version

    RNShake

    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.

    Please note that it only works on real devices

    Installation

    npm install react-native-shake

    or

    yarn add react-native-shake

    Linking the native modules

    Automatic:

    From React Native 0.60, you don't have to manually link libraries anymore. Just

    cd ios
    pod update

    and you're good to go.

    Manual (iOS):

    Follow this guide

    Usage

    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.addEventListener(() => {
          // Your code...
        });
      }
    
      componentWillUnmount() {
        RNShake.removeEventListener();
      }
    }

    Keywords

    none

    Install

    npm i react-native-shake

    DownloadsWeekly Downloads

    8,240

    Version

    4.0.2

    License

    MIT

    Unpacked Size

    23.7 kB

    Total Files

    15

    Last publish

    Collaborators

    • avatar