Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Mastering React Native
Mastering React Native

Mastering React Native: Learn Once, Write Anywhere

eBook
$9.99 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Mastering React Native

Chapter 2. Saying HelloWorld in React Native

Now that we've introduced you to the basics of programming in React, it's time to dig into some of the underlying tools and technologies that make React Native work. This will provide valuable context as you progress through the remainder of this book. We'll also touch on some of the more popular mobile development alternatives to React Native. This will help you understand where React Native fits into the broader mobile development ecosystem and better inform your decision-making as to which technology best suites your mobile requirements.

Once we've completed setting context, we'll switch gears and focus on configuring your computer for running and debugging your very first React Native application using the iOS Simulator. Since our immediate goal is to get you up and running quickly, we'll only focus on configuring your environment for iOS. Chapter 9, Refactoring for Android, is entirely dedicated to...

Understanding the mobile app development ecosystem

When it comes to building mobile applications, the two most popular approaches have been, first, building a native application for each target platform (iOS, Android, and so on), and second, writing a hybrid application by using web technologies (HTML, CSS, JavaScript) and wrapping the app inside of a container WebView using a tool such as Adobe PhoneGap. Each option has its pros and cons. Native applications often feel faster and more responsive. They have built-in support for complex touch gestures and they look and feel consistent with their platform. As a post from the Facebook blog states, the reason we build native apps on these proprietary platforms is that right now, we can create better-feeling experiences that are more consistent with the rest of the platform than we can on the web. (Source: https://code.facebook.com/posts/1014532261909640/react-native-bringing-modern-web-techniques-to-mobile/) However, this comes at a cost...

Understanding all the React Native tools

Like most modern development, there are a few tools required to build a React Native application. Luckily, React Native is pretty easy to configure relative to many frameworks out there. We'll get into installing all these tools shortly. First, let's review what all the tools are how they fit into the bigger picture of developing a React Native app.

Xcode

In order to build an iOS application, you'll need Apple's Xcode IDE. React Native runs on iOS 7 and above. This means that you'll need Xcode version 7.0 or higher. (We'll be using Xcode 8 in this book.) Whether you love, hate, or are altogether indifferent about Xcode, we won't actually be spending much time in it.

Initially, we'll just use Xcode to launch our app in the iOS Simulator. Also, because we'll mostly be testing our app in the iOS Simulator, you don't need to worry about enrolling in the Apple iOS Developer Program. However, if and when you...

Watchman

Watchman is an open source tool created by Facebook (https://facebook.github.io/watchman/). React Native's packager uses Watchman to recursively watch for changes to our source code files across one or more directory trees. Once it detects a change, it automatically rebuilds the JavaScript bundle. This allows us to sidestep one of the slowest and most painful parts of native development.

Much like several of our other tools, once Watchman is installed, you won't have to worry about it. The React Native Package Manager handles running Watchman for us.

Flow

Unlike the other tools mentioned, Flow is entirely optional. Flow is yet another open source tool created by the Facebook team (http://flowtype.org/). It's used to add type annotations to our JavaScript code. JavaScript, as you likely already know, is a dynamically typed language. This means you never need to declare a variable as an int or a string. You just declare a variable and set a value. The type is implicitly...

Installing our tools

At this point, we have covered what each of the tools in our tool chain is responsible for doing. So with that out of the way, let's begin installing each of them.

Installing Xcode

The first thing you'll need to do is ensure you have version 7 or later of Xcode installed. However, I recommend you install Xcode 8 as that's what we'll be using throughout this book. If you already have Xcode installed, verify the version by launching the program and then clicking on Xcode | About Xcode. You should see an image similar to the following screenshot:

Installing Xcode

If you don't have Xcode installed, you'll need to download it from the Apple App Store. To do this, launch the App Store application and search for Xcode using the search bar in the top right corner of the window. Once you find it, click on the Get button and then Install App. You may need to enter your Apple credentials before downloading. The Xcode installer is pretty large, so while we wait on that...

Understanding the mobile app development ecosystem


When it comes to building mobile applications, the two most popular approaches have been, first, building a native application for each target platform (iOS, Android, and so on), and second, writing a hybrid application by using web technologies (HTML, CSS, JavaScript) and wrapping the app inside of a container WebView using a tool such as Adobe PhoneGap. Each option has its pros and cons. Native applications often feel faster and more responsive. They have built-in support for complex touch gestures and they look and feel consistent with their platform. As a post from the Facebook blog states, the reason we build native apps on these proprietary platforms is that right now, we can create better-feeling experiences that are more consistent with the rest of the platform than we can on the web. (Source: https://code.facebook.com/posts/1014532261909640/react-native-bringing-modern-web-techniques-to-mobile/) However, this comes at a cost. For...

Understanding all the React Native tools


Like most modern development, there are a few tools required to build a React Native application. Luckily, React Native is pretty easy to configure relative to many frameworks out there. We'll get into installing all these tools shortly. First, let's review what all the tools are how they fit into the bigger picture of developing a React Native app.

Xcode

In order to build an iOS application, you'll need Apple's Xcode IDE. React Native runs on iOS 7 and above. This means that you'll need Xcode version 7.0 or higher. (We'll be using Xcode 8 in this book.) Whether you love, hate, or are altogether indifferent about Xcode, we won't actually be spending much time in it.

Initially, we'll just use Xcode to launch our app in the iOS Simulator. Also, because we'll mostly be testing our app in the iOS Simulator, you don't need to worry about enrolling in the Apple iOS Developer Program. However, if and when you wish to ship an app to the App Store, you will need...

Watchman


Watchman is an open source tool created by Facebook (https://facebook.github.io/watchman/). React Native's packager uses Watchman to recursively watch for changes to our source code files across one or more directory trees. Once it detects a change, it automatically rebuilds the JavaScript bundle. This allows us to sidestep one of the slowest and most painful parts of native development.

Much like several of our other tools, once Watchman is installed, you won't have to worry about it. The React Native Package Manager handles running Watchman for us.

Flow

Unlike the other tools mentioned, Flow is entirely optional. Flow is yet another open source tool created by the Facebook team (http://flowtype.org/). It's used to add type annotations to our JavaScript code. JavaScript, as you likely already know, is a dynamically typed language. This means you never need to declare a variable as an int or a string. You just declare a variable and set a value. The type is implicitly set based on...

Installing our tools


At this point, we have covered what each of the tools in our tool chain is responsible for doing. So with that out of the way, let's begin installing each of them.

Installing Xcode

The first thing you'll need to do is ensure you have version 7 or later of Xcode installed. However, I recommend you install Xcode 8 as that's what we'll be using throughout this book. If you already have Xcode installed, verify the version by launching the program and then clicking on Xcode | About Xcode. You should see an image similar to the following screenshot:

If you don't have Xcode installed, you'll need to download it from the Apple App Store. To do this, launch the App Store application and search for Xcode using the search bar in the top right corner of the window. Once you find it, click on the Get button and then Install App. You may need to enter your Apple credentials before downloading. The Xcode installer is pretty large, so while we wait on that, you can start downloading the...

Installing Watchman and Flow


Next up are Watchman and Flow. Again, Flow is entirely optional. If you wish to experiment with it, you're welcomed to install it. It won't hurt anything. If you'd rather skip it for now, that's totally fine as well.

From the terminal, run brew install watchman:

And if you wish, run brew install flow.

Installing the React Native CLI

Okay! We're almost done with installing everything. There's just one more it we need: the React Native CLI. Again, from the terminal, run npm install -g react-native-cli. Using npm, this will globally (-g) install the React Native CLI that you'll use to scaffold your React Native applications. However, don't be surprised if you see an error that looks like the following:

This is pretty common permission error. One way to get around this is by prefacing the command with sudo, which will required you type your password. However, we can fix our permissions pretty easily so that sudo is unnecessary. Here are the steps:

  1. Type in npm config get...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Apply flexbox to get layout and build rich animations that bring your React Native application to life
  • Integrate third-party libraries and develop customized components that run natively on iOS and Android platforms
  • Combine React Native with Redux, Redux middleware, and a remote API to build scalable data-driven applications

Description

React Native has completely revolutionized mobile development by empowering JavaScript developers to build world-class mobile apps that run natively on mobile platforms. This book will show you how to apply JavaScript and other front-end skills to build cross-platform React Native applications for iOS and Android using a single codebase. This book will provide you with all the React Native building blocks necessary to become an expert. We’ll give you a brief explanation of the numerous native components and APIs that come bundled with React Native including Images, Views, ListViews, WebViews, and much more. You will learn to utilize form inputs in React Native. You’ll get an overview of Facebook’s Flux data architecture and then apply Redux to manage data with a remote API. You will also learn to animate different parts of your application, as well as routing using React Native’s navigation APIs. By the end of the book, you will be able to build cutting-edge applications using the React Native framework.

Who is this book for?

This book is for anyone who wants to build cross-platform native mobile applications using only JavaScript and the React Native framework. In particular, this book is especially useful for front-end developers who want to use their current skillset to build mobile applications. An existing working knowledge of JavaScript will help you get the most out of this book.

What you will learn

  • Implement native React Native components and APIs
  • Explore React's JSX syntax
  • Manage data using Redux and Redux middleware
  • Build applications with React Native on both iOS and Android platforms
  • Perform animations in your applications using the animation APIs
  • Understand routing and Navigator comparison
  • Create your own Native module

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jan 11, 2017
Length: 496 pages
Edition : 1st
Language : English
ISBN-13 : 9781785889790
Category :
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Jan 11, 2017
Length: 496 pages
Edition : 1st
Language : English
ISBN-13 : 9781785889790
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 152.97
React and React Native
$54.99
React Native By Example
$48.99
Mastering React Native
$48.99
Total $ 152.97 Stars icon
Banner background image

Table of Contents

12 Chapters
1. Building a Foundation in React Chevron down icon Chevron up icon
2. Saying HelloWorld in React Native Chevron down icon Chevron up icon
3. Styling and Layout in React Native Chevron down icon Chevron up icon
4. Starting our Project with React Native Components Chevron down icon Chevron up icon
5. Flux and Redux Chevron down icon Chevron up icon
6. Integrating with the NYT API and Redux Chevron down icon Chevron up icon
7. Navigation and Advanced APIs Chevron down icon Chevron up icon
8. Animation and Gestures in React Native Chevron down icon Chevron up icon
9. Refactoring for Android Chevron down icon Chevron up icon
10. Using and Writing Native Modules Chevron down icon Chevron up icon
11. Preparing for Production Chevron down icon Chevron up icon
12. React Native Tools and Resources Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.8
(9 Ratings)
5 star 55.6%
4 star 11.1%
3 star 0%
2 star 22.2%
1 star 11.1%
Filter icon Filter
Top Reviews

Filter reviews by




Harold L. Hunt Oct 28, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book was great for reading in order to create my first demo React Native app. It was easy to follow and understand.I particularly liked that the book started without Redux initially as I found Redux to be rather confusing as first. Getting comfortable without Redux was a huge benefit to me."Mastering" might not be quite accurate... I'd say this is more of a "Getting Started" book. Mastery would require several additional volumes.
Amazon Verified review Amazon
Chris Quin Mar 15, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great book on getting started. While the platform is young it definitely points you in the right direction to become proficient in the API's around react-native.
Amazon Verified review Amazon
Ivan Carmosino May 29, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Partendo dal principio della programmazione react per web (con una infarinatura esaustiva) ti porta nei capitoli successivi a toccare tutti gli argomenti interessanti e utili nella pratica dello sviluppo di una applicazione nativa, inclusa la comunicazione con server api che rilasciano dati/informazioni in json. Per quanto mi riguarda un must!
Amazon Verified review Amazon
Amazon Jason Aug 13, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book provides thorough and easy-to-follow coverage of React Native development. It is written in a mostly conversational style and follows a progression that makes it simple for the reader to work up to a full understanding of each piece of the React Native "puzzle." In fact, if I had to recommend just one book to use for getting into React Native, this would be the one -- it is, in my opinion, the best book on this topic in terms of code style, demonstration of best practices, discussions of alternatives, and logical progression. If I had to make one complaint, it would be that the chapter on navigation does not cover the newest form of navigation that React Native has officially settled on. However, it would be wrong to fault the book for this, because the newest form of navigation was made official after this book was released (and navigation has been a topic that has been very much "in flux" in the React Native community), and the alternative navigation methods discussed in this book do still work. Nevertheless, you may need to supplement that chapter with some reading about the latest "official" React Native navigation solution (called "react-navigation").One other thing: there is a 2-star review on this page that I don't feel is justified. The 2-star review is seemingly based on the fact that this book "assumes you own a Mac," and it complains that "they [i.e., the authors] should mention this fact." Well, the authors *do* mention this, in the early section of the book titled "What you need for this book." The very first thing they say in that section is, "While we will add Android support to our project in later chapters, the majority of this book focuses on iOS development. In order to develop for iOS, you must have access to an Apple Mac computer." So, the 2-star review seems unfair to me in two ways: first, it is wrong in suggesting that the authors do not tell you up-front that you will need a Mac; second, it is wrong to imply that the *whole* of the book focuses on Mac/iOS development -- Android is covered as well.
Amazon Verified review Amazon
Christopher Mann Jan 28, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
If you want to quickly and efficiently build mobile apps using react native then you’ll enjoy this book. The book walks you through the process of building a mobile application, while at the same time drawing comparisons between react native and common web technologies. The book presents a workflow and way of thinking about apps that really speeds up development.I would not recommend this book until you learn the basics of javascript and preferably some of the new ES6 syntax like destructuring, etc. I don’t think you'll need any experience with react - the book does a good job of going over the basic react concepts. The book also provides enough detail on other common technologies (e.g. redux) to allow you to build a fully functional state of the art app.This book is titled mastering react native, and it goes into enough detail that even professionals will find it useful, especially if they want to optimize their workflow / development process.The book contains many hyperlinks out to detailed notes and references on the web, so I personally recommend the kindle version. The links are great if you want to go into more depth on the topics covered in the book.This edition is also very recent and so the code examples and technologies used reflect the latest best practices. The javascript ecosystem is constantly changing so having a recently updated edition is useful.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.