DEV Community

Cover image for React Native app
Ivana
Ivana

Posted on

React Native app

React Native

React Native is an open-source mobile application framework for cross-platform mobile app development for iOS and Android. It let you build native mobile apps using JavaScript. Normally, you’d need to program your mobile app using Java programming language (for Android) and Swift/Obj-C (for iOS). React Native removes that requirement, leading to fully functional apps on both platforms using just one coding language.

Both, React Native and ReactJS were created by Facebook. React Native is being used in thousands of apps, full list can be found here but it's likely you've already used it in one of these apps:
Alt Text

Setting up the development environment

This page will help you install and build your first React Native app.

If you are new to mobile development, the easiest way to get started is with Expo CLI. Expo is a set of tools built around React Native and, while it has many features, the most relevant feature for us right now is that it can get you writing a React Native app within minutes.

You will only need a recent version of Node.js and a phone or emulator.

npm install -g expo-cli
Enter fullscreen mode Exit fullscreen mode

Then run the following commands to create a new React Native project called "NewProject":

expo init NewProject

Enter fullscreen mode Exit fullscreen mode

However, I received this error at the very beginning

ERROR: Node.js v12.10.0 is no longer supported.

expo-cli supports following Node.js versions:
* >=10.13.0 <11.0.0 (Maintenance LTS)
* >=12.13.0 <13.0.0 (Maintenance LTS)
* >=14.0.0 <15.0.0 (Active LTS)
* >=15.0.0 <16.0.0 (Current Release)
Enter fullscreen mode Exit fullscreen mode

After throwing some errors trying to install node-v15.5.0 as supported version, and system fails to overwrite the current version v12.10.0, this fix a problem:

nvm install node --reinstall-packages-from=$(nvm current)

Enter fullscreen mode Exit fullscreen mode

After:

cd NewProject
Enter fullscreen mode Exit fullscreen mode

run:

npm start
Enter fullscreen mode Exit fullscreen mode

This will start a development server for you:
Alt Text

Running your React Native application

Install the Expo client app on your iOS or Android phone and connect to the same wireless network as your computer. Expo is a framework and a platform for React applications that helps develop, build, deploy, and quickly iterate on iOS, Android, and web apps from the same JavaScript/TypeScript codebase.

On Android, use the Expo app to scan the QR code from your terminal to open your project.

On iOS, use the built-in QR code scanner of the Camera app. Running on and starting the Simulator Guides can be found here

Alt Text

Modifying your app

Now that you have successfully run the app, let's modify it by opening App.js in your text editor and edit some lines. The application should reload automatically once you save your changes.

That's it!

Congratulations! You've successfully run and modified your first React Native app.

To connect with me

Please check my Github, LinkedIn and follow me on Twitter.

Thanks for reading!

Top comments (2)

Collapse
 
andrewbaisden profile image
Andrew Baisden

Cool guide works like a treat thanks for posting.

Collapse
 
ivanadokic profile image
Ivana

Thank you @andrewbaisden