Book Image

React Native By Example

By : Richard Kho
Book Image

React Native By Example

By: Richard Kho

Overview of this book

React Native's ability to build performant mobile applications with JavaScript has resulted in its popularity amongst developers. Developers now have the luxury to create incredible mobile experiences that look and feel native to their platforms with the comfort of a well-known language and the popular React.js library. This book will show you how to build your own native mobile applications for the iOS and Android platforms while leveraging the finesse and simplicity of JavaScript and React. Throughout the book you will build three projects, each of increasing complexity. You will also link up with the third-party Facebook SDK, convert an app to support the Redux architecture, and learn the process involved in making your apps available for sale on the iOS App Store and Google Play. At the end of this book, you will have learned and implemented a wide breadth of core APIs and components found in the React Native framework that are necessary in creating great mobile experiences.
Table of Contents (17 chapters)
Title Page
About the Author
About the Reviewer
Customer Feedback


React Native is an incredibly powerful framework that makes development on multiple platforms more accessible for web-centric programmers. In this book, you are going to learn how to build mobile applications using React Native that are ready to be deployed to both the iOS App Store and Google Play.

What this book covers

Chapter 1, First Project - Creating a Basic To-Do List App, begins the process of writing a to-do list application with React Native. You will plan the app and gain an overview of StyleSheet, Flexbox, and ES6. You will also create the building blocks of the app with four different parts of the React Native SDK.

Chapter 2, Advanced Functionality with the To-Do List App, dives deeper into the app we started build in the first chapter. You will learn how to handle navigation, date and time selection, building buttons, and create a custom collapsible and animated component for use in the app. You will also take those lessons and translate them into an Android version of the app.

Chapter 3, Second Project - The Budgeting App, will begin the second project of the book. You will plan an expense-tracking application, install a third-party vector icon library for React Native, create utility files that can be used throughout the app, and create a Modal component.

Chapter 4, Advanced Functionality with the Budgeting App, is a continuation of the second project. You will learn how to create a dropdown-like component for users to select from a list of items and create tabbed navigation for the app.

Chapter 5, Third Project - The Facebook Client, will begin the third and final project of the book. You will plan an app that connects to the third-party Facebook SDK, install said SDK to your project, allow users to log in with their Facebook credentials, then make requests for information.

Chapter 6, Advanced Functionality with the Facebook Client, wraps up the project you began in the previous chapter. You will learn how to build a pull-to-refresh mechanism for the app, render images for your users, allow users to open links without having to leave the app, and then use those lessons to make an Android version of the app.

Chapter 7, Adding Redux, introduces the popular Redux architecture. You will learn how to convert the to-do list app in the second chapter to an app supported by the principles of Redux.

Chapter 8, Deploying Your Applications, shows you how to package, upload and make your apps available for download on the Apple iOS App Store and Google Play Store. You will also gain some tips on creating app logos and screenshots, as well as how to launch beta tests for your apps.

Chapter 9, Additional React Native Components, dives into parts of the React Native SDK that we were not able to fit into the rest of the book. In it, you will build a playground style app learning different parts of the SDK. You will grab data from any third-party endpoints, control the user’s vibration motor, open other installed apps with links in your app, and much more. You will also learn how to convert the budgeting app in the fourth chapter to Android, since space in that chapter was limited.

What you need for this book

Hardware-wise, you will need a Mac for this book. The content in this book is iOS-first, and to develop iOS apps you must have an Apple computer. Optionally, both an iOS and Android device would be helpful for testing apps on-device, but not mandatory. There is one API in the final chapter of the book that requires a physical device to test (Vibration), and another where testing would be easier on a physical device (Linking).

You will need to install the React Native SDK for your Mac. Instructions can be found at Prerequisites for installing the React Native SDK are available on that page.

Instructions to install Xcode and Android Studio are also available on that same page for installing the React Native SDK to your machine.

Who this book is for

If you are keen on learning to use the revolutionary mobile development tool React Native to build native mobile applications, then this book is for you. Prior experience with JavaScript would be useful.


In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Based on this layout, we see that the entry point for the iOS version of our app is index.ios.js and that a specific iOS folder (and Android for that matter) is generated."

A block of code is set as follows:

class Tasks extends Component { 
  render () { 
    return ( 
      <View style = {{ flex: 1, justifyContent: 'center',  
        alignItems: 'center', backgroundColor: '#F5FCFF'  
        <Text style = {{ fontSize: 20, textAlign:  
          'center', margin: 10 }}> 
          Welcome to React Native! 

Any command-line input or output is written as follows:

react-native init Tasks

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "When you open the Developer menu, you'll see the following options."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.



Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at We also have other code bundles from our rich catalog of books and videos available at Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to  and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.


If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.