1
- import React , { useEffect , useState } from 'react' ;
2
- import { FlatList , Alert } from 'react-native' ;
1
+ import React , { useEffect , useState } from 'react' ;
2
+ import { FlatList , Alert } from 'react-native' ;
3
3
import Geolocation from 'react-native-geolocation-service' ;
4
4
5
5
import Styled from 'styled-components/native' ;
@@ -46,7 +46,7 @@ interface IWeather {
46
46
weather ?: string ;
47
47
isLoading : boolean ;
48
48
}
49
- const WeatherView = ( { } : Props ) => {
49
+ const WeatherView = ( { } : Props ) => {
50
50
const [ weatherInfo , setWeatherInfo ] = useState < IWeather > ( {
51
51
temperature : undefined ,
52
52
weather : undefined ,
@@ -58,32 +58,32 @@ const WeatherView = ({ }: Props) => {
58
58
isLoading : false ,
59
59
} ) ;
60
60
Geolocation . getCurrentPosition (
61
- position => {
62
- const { latitude, longitude } = position . coords ;
61
+ ( position ) => {
62
+ const { latitude, longitude} = position . coords ;
63
63
fetch (
64
- `http://api.openweathermap.org/data/2.5/weather?lat=${ latitude } &lon=${ longitude } &APPID =${ API_KEY } &units=metric`
64
+ `http://api.openweathermap.org/data/2.5/weather?lat=${ latitude } &lon=${ longitude } &appid =${ API_KEY } &units=metric` ,
65
65
)
66
- . then ( response => response . json ( ) )
67
- . then ( json => {
66
+ . then ( ( response ) => response . json ( ) )
67
+ . then ( ( json ) => {
68
68
setWeatherInfo ( {
69
69
temperature : json . main . temp ,
70
70
weather : json . weather [ 0 ] . main ,
71
71
isLoading : true ,
72
72
} ) ;
73
73
} )
74
- . catch ( error => {
74
+ . catch ( ( error ) => {
75
75
setWeatherInfo ( {
76
76
isLoading : true ,
77
77
} ) ;
78
78
showError ( '날씨 정보를 가져오는데 실패하였습니다.' ) ;
79
79
} ) ;
80
80
} ,
81
- error => {
81
+ ( error ) => {
82
82
setWeatherInfo ( {
83
83
isLoading : true ,
84
84
} ) ;
85
85
showError ( '위치 정보를 가져오는데 실패하였습니다.' ) ;
86
- }
86
+ } ,
87
87
) ;
88
88
} ;
89
89
@@ -98,7 +98,7 @@ const WeatherView = ({ }: Props) => {
98
98
} , [ ] ) ;
99
99
100
100
let data = [ ] ;
101
- const { isLoading, weather, temperature } = weatherInfo ;
101
+ const { isLoading, weather, temperature} = weatherInfo ;
102
102
if ( weather && temperature ) {
103
103
data . push ( weatherInfo ) ;
104
104
}
@@ -118,13 +118,13 @@ const WeatherView = ({ }: Props) => {
118
118
< LoadingLabel > Loading...</ LoadingLabel >
119
119
</ LoadingView >
120
120
}
121
- renderItem = { ( { item, index } ) => (
121
+ renderItem = { ( { item, index} ) => (
122
122
< WeatherItemContainer >
123
123
< Weather > { ( item as IWeather ) . weather } </ Weather >
124
124
< Temperature > ({ ( item as IWeather ) . temperature } °C)</ Temperature >
125
125
</ WeatherItemContainer >
126
126
) }
127
- contentContainerStyle = { { flex : 1 } }
127
+ contentContainerStyle = { { flex : 1 } }
128
128
/>
129
129
</ Container >
130
130
) ;
0 commit comments