gpt4 book ai didi

javascript - 指南针使用expo记录磁力计的值?

转载 作者:行者123 更新时间:2023-12-01 00:37:05 26 4
gpt4 key购买 nike

我想制作一个应用程序,使指南针和指南针应该随着磁力计方向的变化而变化。下面附加的代码显示了一个奇怪的错误。虽然我已经运行 npm install react-timer-mixin 来解决问题。通过在 Expo 上运行此代码,它会显示类似

的错误

Super expression must either be a null or a function.

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',
},
});

The development server returned response error 500

最佳答案

一些修复:1.

import React, {Components} from 'react';

import * as React from 'react';

2.

 componentDidMount(){
this._setupMagnetometerAsync();
}

 componentDidMount(){
this._setMagnetometerAsync();
}

3.

 export default class App extends Components{

export default class App extends React.Component{

关于javascript - 指南针使用expo记录磁力计的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58039015/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com