import Geolocation from 'react-native-geolocation-service
const [lat, setLat] = useState(0)
const [lon, setLon] = useState(0)
() => {}
let response = Geolocation.requestAuthorization('whenInUse').then(x => { if (x == 'granted') { } }
Geolocation.getCurrentPosition(position => { })
setLat(position.coords.latitude.toFixed(0))
setLon(position.coords.longtitude.toFixed(0))
const [weatherData, setWeatherData] = useState(0)
const getWeather = async ( ) => { }
const weather = await fetch([указываем ссылку на API в обратных кавычках, в полях lat и lon оставляем ссылки на состояние приложения]&appid=[API-ключ])
const data = await weather.json()
setWeatherData(data.main.temp)
<Text style={{color: 'red', marginHorizontal: 'auto', fontSize: 40}}> </Text>
[какой-то текст] {weatherData.toFixed(0)}
<TouchableOpacity style={{borderWithin: 2, borderRadius: 10, padding: 5}} onPress={getLocationWeather}> </TouchableOpacity>
<Image style={{width: 20, height: 20}} source={require('./gps.png'} />
const [city, setCity] = useState('')
<Button>
title="get weather"
onPress={getWeatherInTheCity}
const getWeatherInTheCity = async () => { }
const geo = await fetch('https://api.openweathermap.org.geo/1.0/direct?q=${city}&limit=5&appid=[API-ключ]'
const data = await geo.json()
setLat(data[0].lat.toFixed(0))
getWeather()