Intro to React Native: Develop mobile apps

tusharyaar

Tushar Agrawal

Posted on February 4, 2023

Intro to React Native: Develop mobile apps

So you want to develop a mobile application, but don't want to learn the the platforms' native language (swift for iOS or Java/Kotlin for Android), or you just stumbled upon this post and wondered what react native is; well, this post if for you. Note, I won't go into actual coding but rather into a glimpse of react native world.

What is React Native?

Simply put, react native or RN is a JavaScript framework which allows you to write native apps using JavaScript. Note I said native apps instead of mobile apps. Reason? I will go in-depth later, but using react native you can write mobile apps (iOS and Android), desktop apps (Windows and MacOS) and heck, even VR. Though in this post, I will mainly focus on mobile apps. It is maintained by Meta (formally Facebook) and was released in 2015. As of writing (February, 2023), 0.71 is the latest release.

Do companies use React Native?

Short answer, Yes. Many companies use react native for their mobile apps like Tesla, Microsoft, and many companies are migrating to react native, like Shopify. You can read their migration blog here.
You can also look into the entire React Native Showcase.

What are some benefits of using React Native?

1. Single code base

You only need to learn 1 language and you can code apps for both Android and iOS. Also you get other benefits of maintaining a single code base like less time to market, faster MVP, etc.

2. Easy Development Environment

It doesn't forces you to work with XCode or Android Studio, heck it doesn't even require you to have them installed (if you use expo, more on that later). You can work with any IDE of your choice, even notepad.

3. Share Code with web

Since it uses Javascript, and if you have a website as well, you could share some of the logic, thus saving your time and sanity.

4. Community

React Native, as with any Javascript framework, benefits from its MASSIVE community. Also most of the packages that work for react, work for react native as well, and for those that doesn't, there are packages for that as well.

5. Other Benefits

These benefits aren't exactly exclusive to RN but it enjoys those features such as OTA (over-the-air) Updates, Hot Reload in development and Component Libraries.

So are there any Prerequisites?

As with any framework, yes there are some Prerequisites, and some things that are good to know.

Prerequisites

These are the things that are more or less required before you get started with React Native.

1. Javascript

Javascript is a programming language of the web. Though it is used to write anything and its about time you learn Javascript if you haven't already.

“Any application that can be written in JavaScript, will eventually be written in JavaScript.” - Atwood's Law

2. React

According to me learning react is a must before you get into React Native, though some might disagree. Why you ask? In a way, you can put react native as a separate framework which builds upon react, so if you are learning react-native you indirectly are learning react. It would be like learning to ride a motorcycle without learning to ride a bicycle.

Good To Know:

1. Typescript

Typescript is basically Javascript, but more strict. It add types to Javascript, which leads us to writing less error prone code. It also enables auto complete on VSCode, which is nice to have.

2. Android Studio or XCode

This is more of a good to have software. I know that I mentioned that you can work without it, but then you will have to plug your phone every time you develop, which is cumbersome. Also these software provide emulators, which you can use which is much easier, and also provide some other tools for performance measurement and enhancement.

Are there any Caveats?

Well, yes.

1. Performance

Compared to Native App, it still lags in performance. Though its not like it is extremely slow. Practically speaking, you will not even see the difference, its only when you compare side by side, you might see react native app lag behind by a few micro seconds.

2. Middle of Migration

So currently, react native is in the middle of migrating to a new architecture. This is not something you need to worry about but the library developers, so you might face some incompatibility when upgrading dependencies, so be sure to check the docs.

3. Custom Modules

This mainly concerns the hardcore developers with extremely niche scenario, but you might not find some components and will have to write your own in native language.

Getting Started

So now you are all pumped up to get started, we can start. However, as mentioned earlier I am not going to be teaching how to write RN apps, for that there are plenty of tutorials out there on YouTube and Udemy. What i will provide though is a guide to how to proceed.

The best way to get into RN development without getting overwhelmed is expo.

What is Expo?

Expo is a managed framework on react native. For my React friends, consider Next.js for React. For my non-react friends, consider Automatic transmission car for a Manual Transmission Car. It reduces complexity, add features and makes its a pleasant drive.
One cannot praise expo enough for how much its makes developing in react native easier. Simplicity, high quality documentation and libraries are not just the only features to use expo. Its services, like Expo Application Service (EAS) lets you build for iOS even without owning a MAC. It also makes OTA updates super easy. And the best part, you won't even have to leave expo until you are one of those niche developers with specific use case that expo doesn't have. So remember I said RN is in the middle of an architecture migration, expo handles that as well, so you don't have to worry about incompatibility.

So yes, head to Expo Docs to get started. What I would suggest is do as many projects as you can to get good at it, and make sure to learn something new in every project you make.

What are Other good to know things about React Native?

Develop for any Platform

As I said earlier, using react native you can develop for any platform and not limited to mobile. But its not as easy as it sounds like.
For desktop apps, React native Windows is used which is maintained by folks at Microsoft, and still in active development, so a lot of things might change.
For VR app, ViroReact is used, which is again is in active development. So its development is not as convenient as expo, and for someone new to react native, i won't suggest going that route. But once you are experienced, not one is stopping you and these are great technologies to develop native apps.

Update apps Over the Air

Over the Air (OTA) updates allow you to push minor updates to apps without having to wait for an approval. The process for publishing apps to play store and app store is, after you publish and update your app requires an approval before it is pushed to your users. This is a great policy but its becomes unnecessary when you might just need to update some spelling mistakes. This is when you can use OTA updates to instantly update the app, without going through the whole approval process. And yes it is allowed, as long as you don't change the functionality drastically.

You can use native code as well

Yes RN mainly is about writing Javascript for making you apps, but you can also write components and functions in native language, and use it. And that's actually how meta uses RN in their apps. They have not, and probably will not migrate their native app to react native, but only some screens use react native.

Can You make games?

Can you use an aircraft to travel 1km ? Yes you can, whether or not you should, depends on your use case. Though if you really want to, you can look into react-native-game-engine.

How can join the community?

React Native Community is extremely welcoming, and it would be great to have you. Have a look at the following resources, and join them if you like:

Subreddits
Twitter Accounts
Blogs
Podcast
Conferences

Conclusion

React Native is a great framework, and I have been working with it for a year now. It is a great time to learn react native when many companies are considering react native for their new apps.
If you do decide to learn react native let me know, it would be an incredible and exciting journey.

If you made this far, thanks for reading. It was my first post in a way and hope you liked it. If you have any suggestions or if I missed something, let me know.

💖 💪 🙅 🚩
tusharyaar
Tushar Agrawal

Posted on February 4, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related