EXPO! How expo differs from react native? Should I start my project with expo? Many questions arise in newbies mind when he/she wants to get a start in the app development journey.
But, you are lucky as you have landed in the right place. I will try my best to explain everything in a simple manner.
As per official documentation of react native, it is used to:
Let me elaborate it in a simple manner.
Learn Once, Write Everywhere
React native components like view and text behaves like web components ‘div’ and ‘span’. The styling in react native gives you feel like CSS. The only difference is, in react native, field names are written in CamelCase (say fontSize) instead of dashed style (say font-size). It gives a feel of writing web apps.
Wait! This may arise another question of learning react.js before react native. I would say..no! You can start. I have started my react native journey without react.js knowledge, but yeah, there is a need to have some of the basic react components knowledge like JSX, components, state, and props.
I hope you got some pictures of react native. Now let’s explore the market who is using react native. There are many popular apps who are built using react native like Facebook, uber, Skype, Instagram… and maybe one day your app can come in this list!
Now, let’s explore what expo is? How it differs from react native?
According to expo official documentation,
Expo apps are actually react native apps. The only difference is expo comes with its SDK (expo SDK) that provides us services like push notification, Facebook and Google login in just a few lines of code. It allows us to start our project in a minute. We don’t need Xcode (for iOS) & an Android studio (for Android) to get started. So, it’s easier to start.
Now, you might wonder why the hell I would start my journey with react native. I will use expo. But there is a quote by Brom:
“Everything comes with a price”.
Expo is good to start but it has some disadvantages. Let’s list down the advantages and disadvantages of an expo.
- Project setup is so easy and can be done in minutes.
- App sharing is easy (using the QR code and link). You can publish your app using ‘expo publish’ command and can share that link. No need to build .apk(for Android) and .ipa(for iOS).
- Expo can build both .apk and .ipa very easily.
- It provides services like Facebook, Google login, push notifications which you can easily integrate into your app without putting so much effort.
- The biggest advantage which I faced was apk or ipa size. Yes, basic ‘hello world’ app is about 20 to 25 MB big. The reason is integrated libraries.
- You can’t use native modules that is written in Java/Objective-C.
That’s it! This is all about react native with expo.
Wait! we know what expo is. What’s its relation with react native but how to set up the project with expo, from where to start? Here are the answers to your questions.
Let’s start with the setup of your first react native project with expo.
Assuming that you have installed NodeJS (if not, follow this link). Now, install expo-cli command line utility using npm :
npm install -g expo-cli
This will install expo-cli in your machine. Before moving ahead, I would like to tell you about the two main parts of it :
First part is an expo-cli. It is a tool that helps us in our development process like in setup of our project, in building apk or ipa, etc. The second part is expo client app which we have to install on our Android or iOS phone to scan the QR code (which you can get using ‘expo start’ command) that will open a project in our Android or iOS phone. Confused!
If you don’t get it. It’s fine, I am going to explain it step by step.
After installing expo-cli, let’s create your project using:
expo init myApp
It will ask about choosing a template. Go with blank by pressing enter. You can also explore the second one with examples as well. Right now, go with blank and then follow below two commands to run your project.
cd myApp expo start
This will generate QR code.
Generated QR code
Next step is to install expo client app. Expo client app can be installed using play store(for Android) and app store (for iOS) in your phone.
Now, it’s time to run your first react native application using expo. You can see your first app by scanning the QR code (that was generated in your terminal) using an expo client app (which you have installed on your Android or iOS phone). In Android, as soon as you scan, it will compile/bundle your project to run on your device.
Bundling of project is taking place. App will run on your device after completion of bundling process.
Wait! You might think in the same way you can run on your iOS device which is somehow right, but scanning of the QR code is done using a camera. (QR Scan feature has been removed in Expo for iOS). Just open your camera and as soon as you scan, a notification will come->open your app in the expo. Click on it, it will start compiling/bundling your app to run on your iOS device.
Click on the notification, it will start bundling process.
Hurray! you have successfully run your first app using expo.
Isn’t it an easy process. You can modify your code of app.js and see automatic reloading of your app once you save your changes.
Thanks for reading!
- What is the difference between React Native and React?
- Introduction to React Native
- How React Native works?
- Why You Should Choose React Native?
- Component State in React Native
- Getting started with React Native? Read this first !
- Top Programming Languages for Android App Development
- Android App Development Fundamentals for Beginners
- Why Kotlin will replace Java for Android App Development
- App Development for Android in 2017: Challenges and Solutions
- Resolving frequently occurring errors in Android Development
- ReactJS | State in React
- React.js (Introduction and Working)
- Hybrid Apps vs Native Apps | Which one to choose?
- What is full stack development ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : AnchalNigam