5.6.2 • Published 2 months ago

react-native-shake v5.6.2

Weekly downloads
6,224
License
MIT
Repository
github
Last release
2 months ago

React Native Shake Event Detector

If you like this, please consider...

Thank you!

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.addListener(() => {
      // Your code...
    });
  }

  componentWillUnmount() {
    RNShake.removeListener();
  }
}

// For v5.x.x onwards:
import React from 'react'

export const MyComponent = () => {
  React.useEffect(() => {
    const subscription = RNShake.addListener(() => {
      // Your code here...
    })

    return () => {
      // Your code here...
      subscription.remove()
    }
  }, [])
}
5.6.2

2 months ago

5.6.0

4 months ago

5.5.1

7 months ago

5.5.2

7 months ago

5.5.0

9 months ago

5.4.0

11 months ago

5.3.2

1 year ago

5.3.1

1 year ago

5.3.0

1 year ago

5.2.1

1 year ago

5.2.0

1 year ago

5.1.1

2 years ago

5.1.0

3 years ago

4.0.0

3 years ago

4.0.2

3 years ago

3.5.2

3 years ago

3.5.0

4 years ago

3.4.0

5 years ago

3.3.1

5 years ago

3.3.0

5 years ago

3.2.4

5 years ago

3.2.3

5 years ago

3.2.2

6 years ago

3.2.1

6 years ago

3.2.0

6 years ago

3.1.3

7 years ago

3.1.2

7 years ago

3.1.0

7 years ago

3.0.9

7 years ago

3.0.6

7 years ago

3.0.5

7 years ago

3.0.4

7 years ago

3.0.3

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago