React Native module for iOS & Android to receive compass heading
yarn add react-native-compass-heading
import { View, Text } from 'react-native';
import React, { useEffect, useState } from 'react';
import CompassHeading from 'react-native-compass-heading';
export default function App() {
const [headingValue, setHeadingValue] = useState(0);
useEffect(() => {
const degree_update_rate = 3;
CompassHeading.start(degree_update_rate, ({heading, accuracy}) => {
setHeadingValue(heading);
});
return () => {
CompassHeading.stop();
};
}, []);
return (
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: 'white'}}>
<Text>{headingValue}</Text>
</View>
);
}
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Made with create-react-native-library