Я хочу создать приложение, в котором компас и компас должны меняться с изменением направления магнитометра.Приведенный ниже код показывает странную ошибку.Хотя я запустил npm install react-timer-mixin
для решения проблемы. При запуске этого кода на Expo он выдает ошибку типа
Супер-выражение должно быть либо нулевым, либо функцией.
import React, {Components} from 'react';
import {Image, ImageBackground, View, Text, StyleSheet} from 'react-native';
import Expo from 'expo';
export default class App extends Components{
state={
isReady: false,
v: null,
};
_setMagnetometerAsync = async() =>{
Expo.Magnetometer.addListener((v)=>{
this.setState({v});
});
}
componentDidMount() {
this._setupMagnetometerAsync();
}
render(){
return(
<View style = {styles.container}>
<Text>{JSON.stringify(this.state.v)}</Text>
<ImageBackground
source = {require('./compassFace.png')}
style = {{
height: 320,
width: 320,
paddingTop:Expo.Constants.statusBarHeight,
alignItems: 'center',
justifyContents: 'center',
}}>
<Image
source = {require('./CompassNeedle.png')}
style={{
height: 420,
width: 420,
opacity: 0.65,
}}
/>
</ImageBackground>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#ecf0f1',
},
paragraph:{
margin: 24,
fontSize: 18,
fontWeight: 'bold',
textAlign: 'center',
color: '#34495e',
},
});