Getting Started with React Native: How To Set Up From Scratch – Starweaver
getting-started-with-react-native

getting-started-with-react-native

React Native is a game-changer for developers. After only a few years, it's already being used for commercial applications by organizations that include Bloomberg, Uber Eats, and Instagram. It does use the same coding principles as React, which can be confusing, but some differences set them apart. The primary one being that React Native runs In the background so your user experience with an app stays the same on all platforms.

Since React Native uses React coding, developers are easily confused about what the differences are. They also wonder if it's difficult to use it to create a React Native app.

Understanding React Native

If you've previously developed apps, you're probably familiar with React. Like the original, React Native also uses the JavaScript library to build user interfaces, but it also takes advantage of ReactDOM. React Native also allows developers to create apps that are supported by iOS and other platforms. You only need to create one code for your app to work across multiple platforms. It saves organization and developers time and money, which is adding to its appeal.

Since it is an application that works across multiple platforms, you only need to be familiar with JavaScript, CSS, and HTML. For many app developers, this takes a lot of the time and hassle out of creating apps that work on different platforms while also giving users a uniform experience.

Now that you have a general idea of what React Native is, the next step is learning how to set the app up.

React Native Set-Up Guide

There are two methods you can use Reactive Native for app set up. The first is React Native CLI Quickstart and the other is Expo CLI Quickstart. Both will help you create exciting and user-friendly apps but if your new to developing, it's best To start learning with Expo.

The reason is simple, it acts similar to training wheels on a bicycle. It takes care of the mundane tasks so you can concentrate on developing the app. You can switch out of Expo anytime if you need to customize the app for a specific platform.

React Native App Set-Up Guide

Using Expo for the app set up is best if this is your first time. It means that you won't have to install XCode and Android studio. You will need a Macbook if you want to run the app stimulation unless you use Expo.

Step 1: Download NodeJS

Without NodeJS, you won't advance to the next step. It's that important, and also easy to download. You'll find it on their website which will guide you through the installation steps.

You need NodeJS To execute Javascript on the specific system, either React Native or React. The difference is that only React Native uses Javascript to create the apps' native code.

Step 2: Find the CLI

You'll find that this is one of the easiest steps In setting Up a React Native app. Getting access to Expo means that you need to run the "npm install" tab that pops Up on the screen during the download. It will request a command that is "npm install expo-cli --global".

It's also listed on the NodeJS website. It's a simple step that shouldn't cause any problems.

Step 3: Boot Up

You'll need To use this command To initiate Expo, "expo init new-project-name-here". The next step is To choose a template. It's best if you start with the "blank" template. There is another option 'bare-minimum" but it won't start the React Native app unless you have previously downloaded Expo.

The program may ask you for the name of the app after you've pressed "enter", and also for a slug. Don't worry about this now, you can change the default settings to your preferences later on.

Try pressing the "enter" key again. If you have Yarn installed on your device, you'll be asked if you want To use it To install the dependencies. You don't have To use Yarn. If you don't, the dependencies will be installed with "npm".

Finally, "cd" into the generated folder and use "expo start" as the command. Next, enter In "cd new-project-name-here expo start", this will get your Expo app running smoothly.

Sometimes, there are issues with the Expo app, but there are steps you can take that will correct the problems.

How To Fix Common Expo Problems Before Running the App

No matter How careful you are during the download, problems can still pop-up. There are some easy fixes for most of these issues.

Input is Required

If you get the message, "Input is required, but Expo CLI is In non-interactive mode", you probably have git bash active. It tends to ignore Expo commands, which results In the error message. If you switch to "cmd", this should resolve the problem.

Update Now

One message that can appear is, "there is a new version of expo-cli available". Once you've installed the new version, everything should work fine.

Expo Crashes

Sometimes Expo will start but crashes before opening. When this happens, it might be due to NodeJS. Not all versions are compatible with Expo-CLI. You might need an up or downgrade for one or both components. To change the NodeJS version on Windows, you will need to uninstall it before installing the correct one.

Code Won't Scan

Since the code is on your screen, it might be a problem with the camera on your phone. Sometimes, it takes a few tries before the camera can 'read' the code.

These are the common problems that developers encounter when they're downloading Expo.

How To Run the App

Previewing the React Native app is as simple as setting it up. On your mobile device run, "expo start". You'll get a QR code that needs to be scanned with your device. You'll find the app In the device's "play-store".

The purpose of the QR code is to give you instant feedback on any changes you made In the code. The automated feedback gives you an idea of how the app is working and will be received across different platforms.

Conclusion

What React Native does is keep apps the same across multiple platforms. This means that regardless of what device you use the app will look and function the same. It's a game-changer for developers, corporations, and consumers.

Setting a React Native app up is simple. It only takes 3 steps before you can preview the app. Even though it helps if you've worked with React before, it's better to know JavaScript since React Native also runs on it.

Except for a few possible bugs, it's that easy to get started with React Native.

WATCH LIVE CLASSES FREE

Learn from Leading Experts | Learn by Doing

Individual Sign-up
Register a Team
(with discounts)

Save even more for teams!
Find out more...

 

Current Streaming Courses

"The secret to getting ahead is getting started..." ~ Mark Twain