React Native module for iOS & Android to receive compass heading
npm install react-native-compass-headingReact Native module for iOS & Android to receive compass heading
``sh`
yarn add react-native-compass-heading
`js
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 (
);
}
``
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
---
Made with create-react-native-library