티스토리 뷰
[React Native] React Native로 날씨앱 만들기 (9) - Displaying Temperature
코딩브론즈 2021. 4. 26. 17:36먼저 온도부터 맞추자. 현재 화씨온도 292.23 를 섭씨온도로 바꿀것이다.

현재 사용하고 있는 API Current weather data 에서 Units of measurement를 보면 2가지 옵션이있다.

units=imperial 과 units=metric 이 있다.
metric은 섭씨온도를 원할때 imperial은 화씨온도이다. 화씨를 누가쓰나? metric을 쓰자
url 뒤에 &units=metric을 붙이고 저장.

화씨온도였던 292 에서 섭씨온도 19도로 바뀐것을 확인할 수 있다.
이제 날씨 정보를 보여줄 Weather.js 컴포넌트를 만들어 보자.
props를 몇개 가질것이기 때문에 prop-types를 install 하자.
npm install prop-types

Weather.js


이제 App.js 에서 Weather 컴포넌트를 가져오자.
Weather 를 가져오면서 prop로 temp를 넘겨준다.


온도를 잘 가져온걸 확인하고 다시 Current weather data API를 보니 아이콘이 있는 Weather Conditions 목록이 있다.
openweathermap.org/weather-conditions
Weather Conditions - OpenWeatherMap
Weather Conditions Home Weather Conditions
openweathermap.org




state에 condition과 isLoading과 temp가 잘 들어왔다.
'React Native' 카테고리의 다른 글
[React Native] React Native로 날씨앱 만들기 (11 完) - Background Gradient (0) | 2021.04.27 |
---|---|
[React Native] React Native로 날씨앱 만들기 (10) - Icons and Styling (0) | 2021.04.27 |
[React Native] React Native로 날씨앱 만들기 (8) - API 사용하기 (0) | 2021.04.26 |
[React Native] React Native로 날씨앱 만들기 (7) - Location & Permissions (0) | 2021.04.26 |
[React Native] React Native로 날씨앱 만들기 (6) - Loading Screen (0) | 2021.04.25 |
- Total
- Today
- Yesterday
- 백트래킹
- 리액트
- 구현
- BFS
- 현꾸라지
- 객체지향
- Spring
- 알고리즘
- map
- S3
- g4
- Spring Boot
- 그리디
- java
- 문자열
- SWEA
- 코딩새내기
- 백준
- S2
- DFS
- react native
- 자바
- G5
- PriorityQueue
- 리액트 네이티브
- 우선순위큐
- laugh4mile
- 시뮬레이션
- react
- 다익스트라
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |