@chenng/react-native-shake-event

1.0.4 • Public • Published

Source

author: Jadson Lourenco jadsonlourenco@gmail.com

homepage: https://github.com/jadsonlourenco/react-native-shake-event

Notes: Source can not be used directly, republish it...


Add the shake event on your React Native app, giving to users improved usability. Enjoy! (works only on real device)

Install

$ npm install @chenng/react-native-shake-event --save

Linking Libraries

react-native link @chenng/react-native-shake-event

Usage

import RNShakeEvent from 'react-native-shake-event';

class MyComponent extends React.Component {
  componentWillMount() {
    RNShakeEvent.addEventListener('shake', () => {
      console.log('Device shake!');
    });
  }

  componentWillUnmount() {
    RNShakeEvent.removeEventListener('shake');
  }
}

API

RNShakeEvent

addEventListener('shake', Function)

Start listening the shake event and handle a callback function.

removeEventListener('shake', Function)

Stop to listening the shake event, and is recommended to prevent memory leak.

Issues

On debug mode this event also handle the DevMenu, but works fine on production.

License

MIT

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @chenng/react-native-shake-event

    Weekly Downloads

    0

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    17.8 kB

    Total Files

    13

    Last publish

    Collaborators

    • chenng