Skip to content

Add shake event to your React Native app

Notifications You must be signed in to change notification settings

getdelta/react-native-shake-event

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-shake-event

npm npm react-native channel on discord

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

Demo

react-native-shake-event

Install

$ npm install react-native-shake-event --save

iOS

Automatic

react-native link react-native-shake-event

Manual
  1. Add the ios/RNShakeEvent.xcodeproj file to your Xcode project Demo;
  2. Add the Products/libRNShakeEvent.a file to Build Phases Demo.

This step is described here: Linking Libraries.

Android

react-native link 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

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

License

MIT

About

Add shake event to your React Native app

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 45.1%
  • Objective-C 35.9%
  • JavaScript 12.1%
  • Ruby 6.9%