Giter Site home page Giter Site logo

tradebulls / react-native-shake Goto Github PK

View Code? Open in Web Editor NEW

This project forked from doko-demo-doa/react-native-shake

0.0 0.0 0.0 81 KB

React Native shake event detector

License: MIT License

JavaScript 4.11% Ruby 4.99% Objective-C 22.70% Java 63.73% TypeScript 4.46%

react-native-shake's Introduction

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.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()
    }
  }, [])
}

react-native-shake's People

Contributors

doko-demo-doa avatar codemers avatar harunsmrkovic avatar msftenhanceprovenance avatar mirocosic avatar wouterds avatar zi6xuan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.