2Hats . 2 minutes
January 24, 2019

Getting started with react-native-navigation (V2) for beginner

Once you become familiar with react-native components and start designing pretty screens, the next question is how to navigate between screens. The solution comes in the form of some navigation libraries like react-navigation, react-native-navigation or so on. I personally prefer react-native-navigation as it is more native than just a react component thus have better performance.

In this tutorial, I will walk you through the installation steps to build a basic navigation structure.

Step 1: create an app with the desired name. You can use the below command to for that:

$ react-native init ProjectName

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Step 2: cd to the project folder and install react-native-navigation. Refer the below terminal command for that:

$ cd ProjectName

$ react-native install react-native-navigation

 

 

 

 

 

 

 

 

 

 

 

Step 3: Android installation. For this, you can follow the instruction in below link

https://wix.github.io/react-native-navigation/#/docs/Installing?id=android

Do as it is said up to step 7.1.

Android gradle is a plugin based build system. so to automate the build as we wish, we can add scripts to build.gradle. addition to the previous steps, you should also edit build.gradle in the app folder add the following dependency to it.

Thus, things are done for android, next we have can start setting up for ios.

For this, we can follow the link https://wix.github.io/react-native-navigation/#/docs/Installing?id=ios

but before that, as we have automatically linked RNN to this project. We just need to follow step 3 in that manual

Implementation

For implementation, I prefer to use an App folder with index.js as base

Here  is a screenshot of my folder structure

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Now in index.js in App folder, import and register screens and setup a layout

You can refer the below code for that

You can refer our repo for codes: https://bitbucket.org/2hatslogic/rnn2sample/

Build your amazing apps now!

Got stuck reach us for all types of react native development services.

 

blog
Greetings! I'm Aneesh Sreedharan, CEO of 2Hats Logic Solutions. At 2Hats Logic Solutions, we are dedicated to providing technical expertise and resolving your concerns in the world of technology. Our blog page serves as a resource where we share insights and experiences, offering valuable perspectives on your queries.
Aneesh ceo
Aneesh Sreedharan
Founder & CEO, 2Hats Logic Solutions
Subscribe to our Newsletter
Aneesh ceo

    Stay In The Loop!

    Subscribe to our newsletter and learn about the latest digital trends.