Build your First App with React Native - MobileAppDaily
app development

Build Your First App With React Native

A simple tutorial to help you build your app with React Native

Build Your First App With React Native

In this article, we will be teaching the basics when it comes to React Native and also further explaining how to create your first app with React Native.

This post can be very useful for those who have only used JavaScript in their coding journey. So, fasten your seat belts and get ready to learn something new.

What is React Native?

In simple words, React Native is a JavaScript library that is used for the purpose of building and developing UI (User Interface). React Native also known as React JS is maintained by the developer’s community of Facebook.

React Native only uses JavaScript for building mobile applications but because JavaScript uses the same design as React JS. The end result gets a very rich mobile user interface from using these declarative components.

We highly encourage those to also read this React app building tutorial who do not have much experience in JavaScript as it is a brief and easy article that provides some valuable insights regarding building a React Native application.

Although it's not a mandatory step but we highly recommend creating a couple of sketch designs regarding your app so that you can get some sort of guidance regarding your app's aim. Creating some sketches is great as you get the rough idea of the app's flow and it also saves a lot of time.

Install React

The first and the obvious step is to install react, here is the LINK where you can download it from. When it comes to building a React Native application, there are two ways by which it can be done:

a) you can use a toolchain for build the app

Or

b) you can move ahead without using any toolchain.

Our team of experts, suggest that it is better to proceed with toolchain as it helps to smoothen out the process of app building. Let's take an example of Expo, a toolchain that was turned into the create-react-native-app library that removes many barriers from the front-end development segment.

For today, let’s move ahead without the use of toolchain but don’t worry in the end of this article we will be sharing few of the most popular reasons why to use React toolchains with you.

Once React is installed start with the Folder Structure

  • Add a folder in the root and name it 'app'
  • Now move the App.js file into the root of 'app'
  • Then update the index.js import statement to 'import App from ./app/App.js'
  • At last, create folders inside 'app'

Few terms and their functions that you need to be aware about:

  1. screens: These are known to be our main views.
  2. assets: There two folders in this directory called images and animations.
  3. components: This is the location where you will put all your shared components.
  4. config: You can set up your app’s color scheme in a colors.js file to keep things managed.

Creating an App

Firstly, install it once globally:

$ npm install -g create-react-native-app

 # or

$ yarn global add create-react-native-app

You need to make sure to use Node v6 or a version after it with npm v3 or npm v4 version of Yarn. We are not asking you to use the npm v5 because of the bugs issues faced in that npm version.

Then to create an app, run:

$ create-react-native-app my-app

$ cd my-app

After running the above mentioned line of codes, a directory will be created by the name 'my-app' inside the current working directory. This will further generate the initial structure of the project inside 'my-app' so go ahead and install all its dependencies.

If you are previous experience with React Native, you will be aware about the fact that you won't be seeing any 'android' or 'ios' directories. So once the installation is complete, some commands are to be run in the project directory by you:

With npm start

It will run your app in development mode with an interactive prompt and to run it without a prompt, use the '--no-interactive' flag.

If you want to view it, then open it in the expo app on your mobile phone to view file. And it will reload itself if you save edits to your files. With this, you can also see the build errors surfaced and logs at the terminal.

With npm test

It runs the JEST test runner for your tests.

With npm run ios

It's like npm start, but this also attempts to open your app in the iOS Simulator if you're on a Mac device or have it installed.

With npm run android

Like npm start, this one also attempts to open your app on a connected Android device or even an emulator. But it requires an installation of Android build tools.

With npm run eject

It will start the process of 'ejecting from Create React Native App's build scripts. And then you'll be asked a few of questions about on how you'd like to build your project.

Reasons to use React Toolchains

Here are the few of the main reasons why you should use React toolchains when building an app with React Native

  • With toolchains, you can perform live-editing CSS and JavaScript in development phase.
  • The React toolchains optimize the output for production.
  • By using toolchains, you can easily detect common mistakes in the early stages.
  • The react toolchains support the third party libraries from the npm versions.
  • Toolchains further help in providing scaling to many components and files.

We hope you liked this short and quick guide on how to build an app using React Native. Also, make sure you stay tuned to get the latest app development tutorials at your fingertips.

Read More About:

Twinkle <span>Product Strategist</span>
Written By

She is an experienced business and marketing consultant of the mobile app industry; advising on anything from the perfect branding to the latest tech releases. She is passionate about writing well-researched reports to help the app owners and the mobile app industry audience. She has a vibrant touch that goes well in her writing as well.

Top Companies

InMobi
Singapore
Dot Com Infoway
New York, USA
M&C Saatchi Mobile
New York City, USA
Techmagnate
New Delhi, India
Fetch
London, UK
View full report

Latest Articles

Join our global community 135K Followers
app development

Are You Using 12-Factor App Methodology ?

4 min read  

In today’s world, most of the SAAS services are being deployed as the web applications. This action requires the development team to deal with many processes to successfully deploy the app. If you are a member of such team then you must know that the process isn't easy, the team encounters

app development

Why Wallet App Startups Fail? Common Mistakes You Should Avoid

4 min read  

Back when Apple launched its first ever wallet app in 2014, few thought that the technology would be as successful as it is today. Now, most consumers prefer wallet apps that render the need to carry cash unnecessary.In fact, the masses carry smartphones that are compatible with wallet apps. Thi

app development

25+ Mobile App Ideas to Skyrocket Your Business (In 2019)

4 min read  

A startup is based on an idea and if the concept is excellent, the chances of reaching the top of the ladder of success increase manifolds. In this era of technological impressions, laying your hands on a mobile app and digitizing your startup is a smart move.This article will give you informati

app development

React.JS Vs Vue.JS: Which JavaScript Framework Is The Best

4 min read  

Which is the best JavaScript Framework between React.JS and Vue.JS?This is the question that a majority of people if not all have been asking for the past few years. And we can understand the reason behind this repetitive question as it is not an easy task to pick one from two of the best JavaSc