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
React Native Cookbook
React Native Cookbook

React Native Cookbook: Recipes for solving common React Native development problems , Second Edition

eBook
₹799.99 ₹2323.99
Paperback
₹2904.99
Subscription
Free Trial
Renews at ₹800p/m

What do you get with a Packt Subscription?

Free for first 7 days. ₹800 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

React Native Cookbook

Creating a Simple React Native App

In this chapter, we'll cover the following recipes:

  • Adding styles to elements
  • Using images to mimic a video player
  • Creating a toggle button
  • Displaying a list of items
  • Using flexbox to create a layout
  • Setting up and using navigation

React Native is a fast-growing library. Over the last few years it has become very popular among the open source community. There's often a new release every other week that improves performance, adds new components, or provides access to new APIs on the device.

In this chapter, we'll learn about the most common components in the library. To step through all of the recipes in this chapter, we'll have to create a new application, so make sure you have your environment up and running.

Adding styles to elements

We have several components at our disposal, but containers and text are the most common and useful components to create layouts or other components. In this recipe, we'll see how to use containers and text, but most importantly we'll see how styles work in React Native.

Getting ready

Follow the instructions in the previous chapter in order to create a new application. We'll name this application fake-music-player.

When creating a new application with Expo, a small amount of boilerplate code will be added to the App.js file in the root folder. This will be the starting point of any React Native application you build. Feel free to remove all boilerplate at the beginning of each recipe...

Using images to mimic a video player

Images are an important part of any UI, whether we use them to display icons, avatars, or pictures. In this recipe, we'll use images to create a mock video player. We'll also display the icons from the local device and a large image from a remote server (hosted by Flickr).

Getting ready

In order to follow the steps in this recipe, let's create a new application. We're going to name it fake-video-player.

We're going to display a few images in our application to mimic a video player, so you'll need corresponding images for your application. I recommend using the icons I used by downloading them from the repository for this recipe on GitHub at https://github.com...

Creating a toggle button

Buttons are an essential UI component in every application. In this recipe, we'll create a toggle button, which will be unselected by default. When the user taps on it, we'll change the styles applied to the button to make it appear selected.

We'll learn how to detect the tap event, use an image as the UI, keep the state of the button, and add styles based on the component state.

Getting ready

Displaying a list of items

Lists are everywhere: a list of orders in the user's history, a list of available items in a store, a list of songs to play. Nearly any application will need to display some kind of information in a list.

For this recipe, we're going to display several items in a list component. We're going to define a JSON file with some data, then we're going to load this file using a simple require to finally render each item with a nice but simple layout.

Getting ready

Let's start by creating an empty app. We'll name this application list-items. We're going to need an icon to display on each item. The easiest way to get images is to download them from this recipe's repository...

Using flexbox to create a layout

In this recipe, we'll learn about flexbox. In the previous recipes in this chapter, we've been using flexbox to create layouts, but in this recipe, we'll focus on the properties we have at our disposal by recreating the layout from a random name generator application on the App Store called Nominazer (https://itunes.apple.com/us/app/nominazer/id765422087?mt=8).

Working in flexbox in React Native is essentially the same as working with flexbox in CSS. This means if you're comfortable developing websites with a flexbox layout, then you already know how to create layouts in React Native! This exercise will cover the basics of working with flexbox in React Native, but for a list of all of the layout props you can use, refer to the documentation on Layout Props (https://facebook.github.io/react-native/docs/layout-props.html).

...

Setting up and using navigation

For any application that has more than one view, a navigation system is of paramount importance. The need for navigation is so pervasive in application development that Expo provides two templates when you create a new application: Blank or Tab Navigation. This recipe is based on a very pared down version of the Tab Navigation app template provided by Expo. We'll still begin the recipe with a Blank app and build our basic Tab Navigation app from scratch to better understand all of the requisite parts. After completing this recipe, I encourage you to start a new app with the Tab Navigation template to see some of the more advanced features we'll be covering in later chapters, including push notifications and stack navigation.

Getting ready

...
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Learn strategies and techniques to face React Native mobile development challenges head-on
  • Explore ways to use iOS and Android for React Native development to maximize code reuse and cohesion
  • Build engaging user experiences with React Native

Description

If you are a developer looking to create mobile applications with maximized code reusability and minimized cost, React Native is what you need. With this practical guide, you’ll be able to build attractive UIs, tackle common problems in mobile development, and achieve improved performance in mobile environments. This book starts by covering the common techniques for React Native customization and helps you set up your development platforms. Over the course of the book, you’ll work through a wide variety of recipes that help you create, style, and animate your apps with built-in React Native and custom third-party components. You’ll also develop real-world browser-based authentication, build a fully functional audio player, and integrate Google Maps in your apps. This book will help you explore different strategies for working with data, including leveraging the popular Redux library and optimizing your app’s dataflow. You’ll also learn how to write native device functionality for new and existing React Native projects and how app deployment works. By the end of this book, you'll be equipped with tips and tricks to write efficient code and have the skills to build full iOS and Android applications using React Native.

Who is this book for?

If you're a JavaScript developer looking for a practical guide for developing feature-rich mobile apps using React Native, this book is for you. Though not necessary, some experience of working with React will help you understand the React Native concepts covered in this book easily. While React Native development can be done on a Windows machine, certain aspects, such as running your apps on iOS devices and in the iOS simulator, or editing native code with Xcode, can only be done with a Mac.

What you will learn

  • Build UI features and components using React Native
  • Create advanced animations for UI components
  • Develop universal apps that run on phones and tablets
  • Leverage Redux to manage application flow and data
  • Expose both custom native UI components and application logic to React Native
  • Employ open source third-party plugins to create React Native apps

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jan 31, 2019
Length: 592 pages
Edition : 2nd
Language : English
ISBN-13 : 9781788991926
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. ₹800 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 31, 2019
Length: 592 pages
Edition : 2nd
Language : English
ISBN-13 : 9781788991926
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
₹800 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
₹4500 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 ₹400 each
Feature tick icon Exclusive print discounts
₹5000 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 ₹400 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 9,459.97
React Native Cookbook
₹2904.99
Hands-On Full-Stack Web Development with GraphQL and React
₹3649.99
React Projects
₹2904.99
Total 9,459.97 Stars icon

Table of Contents

16 Chapters
Setting Up Your Environment Chevron down icon Chevron up icon
Creating a Simple React Native App Chevron down icon Chevron up icon
Implementing Complex User Interfaces - Part I Chevron down icon Chevron up icon
Implementing Complex User Interfaces - Part II Chevron down icon Chevron up icon
Implementing Complex User Interfaces - Part III Chevron down icon Chevron up icon
Adding Basic Animations to Your App Chevron down icon Chevron up icon
Adding Advanced Animations to Your App Chevron down icon Chevron up icon
Working with Application Logic and Data Chevron down icon Chevron up icon
Implementing Redux Chevron down icon Chevron up icon
App Workflow and Third-Party Plugins Chevron down icon Chevron up icon
Adding Native Functionality - Part I Chevron down icon Chevron up icon
Adding Native Functionality - Part II Chevron down icon Chevron up icon
Integration with Native Applications Chevron down icon Chevron up icon
Deploying Your App Chevron down icon Chevron up icon
Optimizing the Performance of Your App Chevron down icon Chevron up icon
Other Books You May Enjoy 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.2
(6 Ratings)
5 star 33.3%
4 star 0%
3 star 33.3%
2 star 16.7%
1 star 16.7%
Filter icon Filter
Top Reviews

Filter reviews by




MG Sep 30, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Informative
Amazon Verified review Amazon
Jordan Jun 04, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I purchased React Native in Action before this book and feel in just the first 2 chapters of this book it covered everything React Native in Action covered in the entire book.I finished React Native in Action and felt like I still had so much more to learn, this book has great depth and I really like that it uses expo to do a lot of its explanation as that's kind of standard at this time.
Amazon Verified review Amazon
MR M J REGAN Oct 21, 2020
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
I was quite enjoying working through the book, however the depreciated ListView component has rendered an example in the 2nd chapter unrunnable. Clearly I could research and fix this, but that is what I do normally. The book was to enable me to get through the work swiftly, at which it has failed. The downloaded online example from Git did not fix this. A question on the subject from July remains unanswered. So all in all, I'm feeling a little deflated. Happy to amend the rating once the issue is resolved in the download.
Amazon Verified review Amazon
PK Sep 23, 2019
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
My main concern with this book is that it uses outdated code. For example, ListView, React Navigation version 1 and componentWillMount are all deprecated, and the newer versions are substantially different. This is a pity, because these crop up throughout the text.The second issue is that the format is confusing. The code is described first once, as it's introduced, and then again, in a section explaining 'how it's done'. There is no obvious reason for this split. The format used in Manning books, in which the code is printed out in full, with annotations explaining each section, would be much more helpful.Third, as with all Packt books, the index is largely useless.On the plus side, this is one of the few Packt books written by someone with a good grasp of English. There are mistakes - such as wrong function names and the usual catalogue of grammatical and punctuation errors - which would have been caught if the proof-reader had done his job. However, unlike with most of Packt's books, this author is a native English speaker, so the quality of the writing is good enough that a few mistakes don't matter too much. One gets the feeling that he actually cares about the quality of his work, which is a refreshing change. Having said that, part of the job of a publisher is to edit and proof-read the text. For example, screenshots throughout the book are from the version of Genymotion limited to personal use, showing that the author hadn't bought a licence. This doesn't affect the book, but it does illustrate the total lack of editorial oversight.
Amazon Verified review Amazon
Anónimo Jun 05, 2023
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
Demasiado código repetitivo sin centrarse en el tema que intenta explicar. Se podía haber escrito el contenido relevante con la mitad de las páginas.Las imágenes son en blanco y negro.No aborda librerías disponibles que enriquecen la APP final.
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.