React native 如何在react native中使用加速计传感器查找方向?

React native 如何在react native中使用加速计传感器查找方向?,react-native,sensors,React Native,Sensors,当我移动它(左、右、上、下)时,如何检测方向 我安装了react-native sensornpm安装react-native sensors--save import { accelerometer } from "react-native-sensors"; const subscription = accelerometer.subscribe(({ x, y, z, timestamp }) => console.log({ x, y, z, timestam

当我移动它(左、右、上、下)时,如何检测方向

我安装了react-native sensor
npm安装react-native sensors--save

import { accelerometer } from "react-native-sensors";

const subscription = accelerometer.subscribe(({ x, y, z, timestamp }) =>
console.log({ x, y, z, timestamp })
);
我用上面的代码进行了测试,它工作得很顺利

但是,我怎样才能知道方向呢

当我移动它(左、右、上、下)时,如何检测方向