# rntpc_react-native-shake **Repository Path**: openharmony-sig/rntpc_react-native-shake ## Basic Information - **Project Name**: rntpc_react-native-shake - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: https://gitee.com/openharmony-sig/rntpc_react-native-shake - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-10-14 - **Last Updated**: 2025-05-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 🚨 **重要提示 | IMPORTANT** > > **⚠️ 此代码仓已归档。新地址请访问 [rntpc_react-native-shake](https://gitcode.com/openharmony-sig/rntpc_react-native-shake)。| ⚠️ This repository has been archived. For the new address, please visit [rntpc_react-native-shake](https://gitcode.com/openharmony-sig/rntpc_react-native-shake).** > --- > # React Native Shake Event Detector If you like this, please consider... Thank you! [![Latest version](https://badge.fury.io/js/react-native-shake.svg)](https://badge.fury.io/js/react-native-shake) ![RNShake](rnshake.png) 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 ```sh npm install react-native-shake ``` or ```sh 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 ```bash cd ios pod update ``` and you're good to go. ### Manual (iOS): Follow this [guide](https://reactnative.dev/docs/linking-libraries-ios) ## Usage ```tsx 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() } }, []) } ```