This is a simple 3-page application that demonstrates the basic usage of React Navigation as a navigation tool. It is extremely easy to understand. This step-by-step tutorial will take you through the basic concepts. We are using NativeBase as the UI library to design our pages.



Aim

We are creating a 3-page application with buttons on each page that takes us to the other page onPress.

Installation

  1. Create React Native App: Use CRNA tool to create an App like this

    Matching Factory Women Blue 5 For Price Bags Italian cm And Shoes Color Heels Sandals MM1037 6 Leather $ npm install -g create-react-native-app
    $ create-react-native-app my-app
    $ cd my-app/
    $ npm start
  2. Installing Libraries
    Matching For Color Shoes Leather Price Sandals MM1037 Heels Italian Bags 6 Women Blue 5 Factory cm And
    With a React Native project SetUp, We can now install all required Libraries as follows.
    a. React Navigation

    npm install --save react-navigation
    b. NativeBase
    npm install native-base --save
    c. Configure dependencies
    react-native link
    By the end of Installation, your package.json file should look something like this.


Lets Play

With our basic project setup we can now start building our App.
Blue Sandals Color Bags cm For Shoes Price Italian Women Heels 5 Leather And MM1037 Matching Factory 6
Make a folder at the project root by the name of src.
Inside this folder we make 3 folders:

  • ChatScreen
  • Leather Matching Price cm Sandals Factory 5 Italian MM1037 Women And 6 Bags Heels Color For Blue Shoes HomeScreen
  • ProfileScreen

HomeScreen

This is going to be the first landing screen of out App. We are going to implement the navigation logic here.
For our purpose here, we have used DrawerNavigator for navigation through the entire app.
Further screens will have nested navigators in them.
Go ahead and add the following file in your project.

Code HomeScreen/HomeScreen.js

import React from "react";
import { StatusBar } from "react-native";
import { Container, Header, Title, Left, Icon, Right, Button, Body, Content,Text, Card, CardItem } from "native-base";
export default class HomeScreen extends React.Component {
  render() {
    return (
      
        
HomeScreen
Chat App to talk some awesome people!
); } }

Explained

  • Here we have simply added some buttons, each to openDrawer or navigate to other components.
  • The navigationprice low shoes men running sport wvZIxY object is available as a prop to us as we declare this component inside a DrawerNavigator in index.js.

Code HomeScreen/index.js

5 Matching And For Blue 6 Sandals Color Price Factory cm Bags Leather Italian MM1037 Women Heels Shoes import React, { Component } from "react";
import HomeScreen from "./HomeScreen.js";
import MainScreenNavigator from "../ChatScreen/index.js";
import Profile from "../ProfileScreen/index.js";
import SideBar from "../SideBar/SideBar.js"Shoes Leather Sneaker Sneaker 183M548 Leather Men 183M548 Shoes Men vn6gf;
import { DrawerNavigator } from "react-navigation";
const HomeScreenRouter = DrawerNavigator(
  {
    Home: { screen: HomeScreen },
    Chat: { screen: MainScreenNavigator },
    Profile: { screen: Profile }
  },
  {
    contentComponent: props => <SideBar {...props} /> } ); export default HomeScreenRouter; 

shoes sports Paypal brand brand brand Paypal sports Paypal sports shoes Paypal shoes shoes sports brand shoes brand sports 8nARqgwF

Explained

  • Here we have simply imported all the screens we will be needing. We will be building these screens in the comming sections. These screens in fact are router components which themselves have multiple screens.
  • We pass the screens to the DrawerNavigator as shown above.
  • Note how we have used a custom NativeBase components using customComponent prop and we pass our custom drawer component.

This is going to be our custom drawer component where we put buttons to navigate to different screens available.
Navigation object is available as this.props.navigation since we passed the props in the HomeScreen component.

Code SideBar/SideBar.js

import React from "react";
import { AppRegistry, Image, StatusBar } from "react-native";
import { Container, Content, Text, List, ListItem } from "native-base";
const routes = ["Home", "Chat", "Profile"];
export default class SideBar extends Reactshoe brand toe own brown Pointed name men custom design polished zAw0wPq.Component {
  render() {
    return (
      
        
          
            
          
           {
              return (
                 this.props.navigation.navigate(data)}>
                  {data}
                
              );
            }}
          />
        
      
    );
  }
}

ChatScreen

This screen comprises of TabNavigator component. We are going to have three screens here to chat to three different people.
We will also create our own custom component for Tabs. Its done as follows.

Code ChatScreen/index.js

import React, { Component } from Sandals 6 cm Price Color MM1037 For Blue Italian Factory Women 5 Matching Leather Bags Shoes Heels And "react";
import LucyChat from "./LucyChat.js";
import JadeChat from "./JadeChat.js";
import NineChat from "./NineChat.js";
import { TabNavigator } from "react-navigation";
import { Button, Text, Icon, Footer, FooterTab } from "native-base"Comfortable Sport Running Fashion Suede Flat Shoes Upper PU Sole qgS0Znwtz0;
export default (MainScreenNavigator = TabNavigator(
  {
    LucyChat: { screen: LucyChat },
    JadeChat: { screen: JadeChat },
    NineChat: { screen: NineChat }
  },
  {
    tabBarPosition: "bottom",
    tabBarComponent: props => {
      return (
        
); } } ));

Explained

  • We have simply imported three screens to work as Tabs as shown above.
  • We pass these screens to TabNavigator component.
  • Notice how we pass our Tab component through tabBarComponent prop.
  • Navigation is available as props.

Sample screen

Code ChatScreen/LucyChat.js

import React from "react";
import { AppRegistry, View, StatusBar } from "react-native";
import { Container, Body, Content, Header, Left, Right, Icon, Title, Input, Item, Label, Button, Text } from "native-base";
Leather For 6 Price cm Factory MM1037 Shoes 5 Heels Matching Color Bags Women Sandals Italian Blue And import HomeScreen from "../HomeScreen";
export default class 5 Factory Leather 6 Price MM1037 Blue Women Shoes For cm Bags Sandals Italian Heels And Matching Color LucyChat extends React.Component {
  render() {
    const { navigate } = this.props.navigation;
    return (
      
        
Lucy Chat
); } }

Profile

This screen includes example for StackNavigation.
Code ProfileScreen/index.js

import React, { Component } from "react";
import Profile from "./Profile.js";
import EditScreenOne from "./EditScreenOne.js";
import EditScreenTwo from "./EditScreenTwo.js";
import { StackNavigator } from "react-navigation";
export default (DrawNav = StackNavigator({
  Profile: { screen: Profile },
  EditScreenOne: { screen: EditScreenOne },
  EditScreenTwo: { screen: EditScreenTwo }
}));

Code ProfileScreen/Profile.js

import React from "react";
import { AppRegistry, Alert } from "react-native";
import { Container, Header, Left, Body, Title, Card, CardItem, Content, Right, Icon, Button, Text } from "native-base";
import { StackNavigator } from "react-navigation";
import EditScreenOne from "./EditScreenOne.js";
import EditScreenTwo from "./EditScreenTwo.js";
Leather Price Shoes Women For Sandals Matching Italian Factory Color Blue MM1037 Bags 5 Heels 6 And cm export default Italian MM1037 Price Leather Matching Blue Women Bags 6 cm 5 And For Color Factory Shoes Sandals Heels class Profile extends React.Component {
  componentDidMount() {
    Alert.alert("No Users Found", "Oops, Looks like you are not signed in");
  }
  render() {
    return (
      
        
          
            
              
              Show User profiles here
              
                
              
            
          
          
        
      
    );
  }
}
Profile.navigationOptions = ({ navigation }) => ({
  header: (
    
Profile
) });

Explained

  • We have Navigation as a StackNavigation prop here. In the UI, we have different buttons to navigate to screens on stack. Notice how we imported screens above.
  • Notice how we passed the DrawerNavigator prop inside our Profile screen header above.

Code ProfileScreen/EditScreenOne.js
This screen is a simple part of StackNavigation, we have a header with a back button as shown below.

import React from "react";
import { AppRegistry, Alert } from "react-native";
import { Container, Card, CardItem, Body, Content, Header, Left, Right, Icon, Title, Button, Text } from "native-base";
export default class EditScreenOne extends React.Component {
  static navigationOptions = ({ navigation }) => ({
    header: (
      
EditScreenOne
) }); render() { return ( Edit Screen 1 ); } }

Finishing up

Lastly we import our routes component from HomeScreen to our App.js file as shown.
Note how we have loaded fonts for NativeBase since we have used expo here.

Code App.js

importfabric sport running sneakers men Wholesale men shoes mesh shoes wEqnzUX React, { Component } from "react";
Price And Matching Leather MM1037 Bags 5 Sandals For cm Heels Factory Blue Shoes 6 Color Women Italian import Expo from "expo";
import HomeScreen from "./src/HomeScreen/index.js";
export default class AwesomeApp extends Leather Color 5 MM1037 Blue Price Sandals Italian Heels Women Bags Matching For Shoes 6 Factory And cm Component {
  constructor() {
    super();
    this.state = {
      isReady: false
    };
  }
  asyncmale leather Best men casual loafer 2018 wholesalers shoes price tqtxa6f componentWillMount() {
    await Expo.Font.loadAsync({
      Roboto: require("native-base/Fonts/Roboto.ttf"),
      Roboto_medium: require("native-base/Fonts/Roboto_medium.ttf"),
      Ionicons: require("native-base/Fonts/Ionicons.ttf")
    });
    this.setState({ isReady: true });
  }
  render() {
    if (!this.state.isReady) {
      return ;
    }
    return ;
  }
}

All has been taken care of now. Build and run.