# rntpc_react-native-compass-heading **Repository Path**: openharmony-sig/rntpc_react-native-compass-heading ## Basic Information - **Project Name**: rntpc_react-native-compass-heading - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: https://gitee.com/openharmony-sig/rntpc_react-native-compass-heading - **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-compass-heading](https://gitcode.com/openharmony-sig/rntpc_react-native-compass-heading)。| ⚠️ This repository has been archived. For the new address, please visit [rntpc_react-native-compass-heading](https://gitcode.com/openharmony-sig/rntpc_react-native-compass-heading).** > --- > # react-native-compass-heading credits - https://github.com/vnil/react-native-simple-compass ## Installation `$ yarn add react-native-compass-heading` `$ cd ios/ && pod install && cd ..` ## Usage ```javascript import React, {useState, useEffect} from 'react'; import {Image, StyleSheet} from 'react-native'; import CompassHeading from 'react-native-compass-heading'; const App = () => { const [compassHeading, setCompassHeading] = useState(0); useEffect(() => { const degree_update_rate = 3; // accuracy on android will be hardcoded to 1 // since the value is not available. // For iOS, it is in degrees CompassHeading.start(degree_update_rate, {heading, accuracy} => { setCompassHeading(heading); }); return () => { CompassHeading.stop(); }; }, []); return ( ); }; const styles = StyleSheet.create({ image: { width: '90%', flex: 1, alignSelf: 'center', }, }); export default App; ```