Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
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
$27.98 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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 : 9781785885785
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

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

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

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

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.