Запускаю код в браузере через expo все ок, захожу в expo через приложуху с телефона и сразу сыпет ошибки в то время как в браузере все работает нормально вот ошибка и код:
Error: @react-native-community/geolocation: NativeModule.RNCGeolocation is null.
import React from 'react';
import { StyleSheet, Text, View, Image } from 'react-native';
import Geolocation from '@react-native-community/geolocation';
export default class Weather extends React.Component {
constructor(){
super();
this.state = {
ready: false,
where: {lat:null, lng:null},
error: null,
name: null,
temperature: null,
description: null,
img: null,
}
}
componentDidMount(){
let geoOptions = {
enableHighAccuracy: true,
timeOut: 20000,
maximumAge: 60 * 60 * 24
};
this.setState({ready:false, error: null });
Geolocation.getCurrentPosition(this.geoSuccess,
this.geoFailure,
geoOptions);
}
geoSuccess = (position) => {
this.setState({
ready:true,
where: {lat: position.coords.latitude,lng:position.coords.longitude },
})
let api = `https://api.openweathermap.org/data/2.5/weather?lat=${this.state.where.lat}&lon=${this.state.where.lng}&appid=361f2b91211a4a6883d2798f9ebc3478`
fetch(api)
.then(response =>{
return response.json();
})
.then(data => {
this.setState({
name: data.name,
temperature: Math.round(data.main.temp - 273) + '℃',
description: data.weather[0]['description'],
img: "https://openweathermap.org/img/wn/" + data.weather[0]['icon'] + "@2x.png"
})
})
}
geoFailure = (err) => {
this.setState({error: err.message});
}
render() {
return (
<View style={styles.container}>
{ !this.state.ready && (
<Text style={styles.big}>Using Geolocation...</Text>
)}
{ this.state.error && (
<Text style={styles.big}>{this.state.error}</Text>
)}
{ this.state.ready && (
<View style={styles.container}>
<Text style={styles.big}>{this.state.name}</Text>
<Text style={styles.big}>{this.state.temperature}</Text>
<Image source={{uri: this.state.img}} style={{height: 128, width: 128}}/>
<Text style={styles.big}>{this.state.description}</Text>
</View>
)}
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
textAlign: 'center',
},
big: {
fontSize: 48,
margin: 20
}
});