Create your first React Native mobile app - Haze API App
Your own Haze Air Pollution Index mobile app
Last updated
Was this helpful?
Your own Haze Air Pollution Index mobile app
Last updated
Was this helpful?
In this workshop we will be developing a React Native mobile app using Expo. We will use an API (Application Programming Interface) as the input/resources/database for the mobile application. The app would consume the JSON resources provided by the API to create a presentable interface where the user can check the daily haze Air Pollution Index in their mobile devices.
We will be using online editor as the main tools to create this application.
We will need your iOS or Android phone installed with the, so that the app can tested on your phone.
Understand the basic concept of React/React Native
Publish the app to a website or at least run it on your phone
At least some basic understanding of programming is needed, preferably in JavaScript as this is the main language used throughout this course
Let's fire up to get started.
We will be presented with App.js
in the text editor area, and on the right you will see preview of your app. Where you can toggle between iOS, Android and Web.
To run your phone you can toggle it to iOS/Android and press the "Run on your device" , then scan the QR code using the installed on your phone.
Referring to the code below, the top part consists all the imports, which consists all the library installed using NPM which you can see in your package.json
. The rest are imported from other local file such as the AssetExample
component.
In the render()
function is where we have HTML-like syntax called JSX where we can create the user interface for the app. Component such as Text
, View
can be imported from react native
as shown in line 2. The full list of component can be referred at the.
From line 27 onward we can see the various of styling that has been set, and used by the View
component in line 14 as such View style={styles.container}>
. The styling syntax is similar to that of CSS but camel cased. The full list of supported styling can be referred .
React is a JavaScript library for building user interfaces. It is maintained by Facebook and a community of individual developers and companies. React can be used as a base in the development of single-page or mobile applications, as it is optimal for fetching rapidly changing data that needs to be recorded
In layman term, we can use React to build interactive interface where we can manipulate the data on the screen, fetch data from database etc.
In this workshop we will be using React Native instead React. React Native works the same as React but instead of using div
and dealing with HTML, we would use React Native component like View
and dealing with mobile app libraries.
The added benefit of using React Native is that instead of using Swift and Kotlin/Java to develop iOS and Android app, we could use JavaScript instead where it will be compiled by React Native into the respective code.
React state allow us update a value efficiently in HTML DOM. As shown in the code below
Props allow to pass value or even function to component we created.
You should receive a confirmation email with instruction on making a simple API call with your token
What you learnt here is applicable on both React Native development as well as web development.
After having your own concept of UI, try to create the component that are required in Snack Expo.
You will need to register an account first to get access to the API
You should be presented with a link as shown where you can get a JSON response.
is the full list of API you can give it a try.
To make an API call we would be using which is built in and also commonly being used in modern browser.
In React Native we will be using Flex to layout our UI. Here's the where you could learn how to position any item anywhere with ease.
In this workshop we will be using a third party library called where it provide us with Material Designed style component where we could present our data in a modern and presentable fashion.
Try to have a concept of the user interface, you can sketch out your own or refer to other application. You can have a look at for app design inspiration. Here's an of a pretty good UI for have app. Feel free to search up and draft up your simple UI.
Expo have a built in set of open source icon. Here's the for the full list of icon. Below we have an example on how to implement it.
Here's the from expo for more details
Kindly fill up this so that we could further improve 😊