In this tutorial, I’ll show you to build a simple e-commerce app with React Native.
React Native is a JavaScript framework for writing mobile applications for iOS and Android. It’s based on React and React Native is so popular.
Prerequisites
Before continue reading this tutorial you will need Node.js and npm installed on your machine.
I am going to use Expo for faster development. I’ll explain what is Expo later in this article.
Setting up
Building mobile applications for iOS and Android require installing and configuring XCode or Android Studio. Expo CLI sets up a development environment on your local machine and you can be writing a React Native app within minutes.
Install the Expo client app on your iOS or Android phone and connect to the same wireless network as your computer.
Let’s create a new React Native project:
Going over what we’ll be building in this tutorial
Installing required packages
In this tutorial, we’ll use two libraries:
- react-native-elements: React Native UI elements that are easy to use & really customizable;
- react-navigation: The community solution to navigation in React Native applications.
Once, the required packages are installed, just run npm start
to start the development server.
And then, you will see the following result:
We have two views on the mobile app. We should find a way to move between these views easily.
How the flow will work:
When the application loads, we’ll render the product home page and product details page.
Create a src
folder. And then create a stack navigator and our routes:
This is what a stack navigator looks like: