Getting Started with React Native
By Ethan Holmes and Bray Tom
4/5
()
About this ebook
About This Book
- Learn to design and build a fully-featured application using the newest cutting-edge framework from Facebook
- Leverage your JavaScript skills to become a native app developer
- Develop custom UI components, implement smooth navigation, and access native features such as geolocation and local storage
Who This Book Is For
This book is for web developers who want to learn to build fast, good-looking, native mobile applications using the skills they already have. If you already have some JavaScript knowledge or are using React on the web, then you will be able to quickly get up and running with React Native for iOS and Android.
What You Will Learn
- Set up the React Native environment on both devices and emulators
- Gain an in-depth understanding of how React Native works behind the scenes
- Write your own custom native UI components
- Learn the ins and outs of screen navigation
- Master the art of layout and styles
- Work with device-exclusive data such as geolocation
- Develop native modules in Objective-C and Java that interact with JavaScript
- Test and deploy your application for a production-ready environment
In Detail
React Native is a game-changing approach to hybrid mobile development. Web developers can leverage their existing skills to write mobile applications in JavaScript that are truly native without using cross-compilation or web views. These applications have all of the advantages of those written in Objective-C or Java, combined with the rapid development cycle that JavaScript developers are accustomed to.
Web developers who want to develop native mobile applications face a high barrier to entry, because they are forced to learn platform-specific languages and frameworks. Numerous hybrid technologies have tried to simplify this process, but have failed to achieve the performance and appearance that users expect.
This book will show you all the advantages of true native development that React Native has without the steep learning curve, leveraging the knowledge you already have. We do this by getting you up and running quickly with a sample application. Next, we’ll introduce you to the fundamentals of creating components and explain how React Native works under the hood. Once you have established a solid foundation, you will dive headfirst into developing a real-world application from start to finish. Along the way, we will demonstrate how to create multiple screens and navigate between them,use layout and style native UI components, and access native APIs such as local storage and geolocation. Finally, we tackle the advanced topic of Native modules, which demonstrates that there are truly no limits to what you can do with React Native.
Style and approach
This book provides a simple and easy way to build mobile applications in JavaScript. Each topic takes you through the life cycle of creating a fully-functional native app, with detailed explanations of the entire process.
Ethan Holmes
Ethan Holmes is the author of six books including the novels, Earth's Blood, Water and The Keystone. He is also the author of two collections of short stories, A Multi-Pack of Brain Flakes and Shorts and Other Laundry.. Currently residing in Northern Arizona, he enjoys hiking, playing twelve string guitar, reading, writing and participation in most active sports.
Read more from Ethan Holmes
React: Building Modern Web Applications Rating: 5 out of 5 stars5/5Mobile Application Development: JavaScript Frameworks Rating: 0 out of 5 stars0 ratingsEarth's Blood Rating: 0 out of 5 stars0 ratingsThe Keystone Rating: 0 out of 5 stars0 ratingsLive Your Life in a Crap Free Zone Rating: 5 out of 5 stars5/5Water Rating: 0 out of 5 stars0 ratingsA Multi-Pack of Brain Flakes Rating: 0 out of 5 stars0 ratingsShorts and Other Laundry Rating: 0 out of 5 stars0 ratings
Related to Getting Started with React Native
Related ebooks
React Native By Example Rating: 0 out of 5 stars0 ratingsReact Projects: Build 12 real-world applications from scratch using React, React Native, and React 360 Rating: 0 out of 5 stars0 ratingsGetting Started with React Rating: 0 out of 5 stars0 ratingsReactJS by Example - Building Modern Web Applications with React Rating: 4 out of 5 stars4/5Learn React Hooks: Build and refactor modern React.js applications using Hooks Rating: 0 out of 5 stars0 ratingsTypeScript Essentials Rating: 4 out of 5 stars4/5Node.js By Example Rating: 2 out of 5 stars2/5React Design Patterns and Best Practices Rating: 0 out of 5 stars0 ratingsExpress Web Application Development Rating: 3 out of 5 stars3/5Clean Code in JavaScript: Develop reliable, maintainable, and robust JavaScript Rating: 5 out of 5 stars5/5JavaScript Regular Expressions Rating: 3 out of 5 stars3/5JavaScript Unlocked Rating: 5 out of 5 stars5/5React.js Design Patterns: Learn how to build scalable React apps with ease (English Edition) Rating: 0 out of 5 stars0 ratingsASP.NET Core 3 and React: Hands-On full stack web development using ASP.NET Core, React, and TypeScript 3 Rating: 0 out of 5 stars0 ratingsMastering JavaScript Design Patterns - Second Edition Rating: 5 out of 5 stars5/5Learning jQuery 3 - Fifth Edition Rating: 0 out of 5 stars0 ratingsJavaScript and JSON Essentials Rating: 5 out of 5 stars5/5Learning AngularJS Animations Rating: 4 out of 5 stars4/5ReactJS for Jobseekers: The Only Guide You Need to Learn React and Crack Interviews (English Edition) Rating: 0 out of 5 stars0 ratingsMastering Reactive JavaScript Rating: 0 out of 5 stars0 ratingsMastering JavaScript Object-Oriented Programming Rating: 0 out of 5 stars0 ratingsExploring Web Components: Build Reusable UI Web Components with Standard Technologies (English Edition) Rating: 0 out of 5 stars0 ratingsJasmine JavaScript Testing - Second Edition Rating: 0 out of 5 stars0 ratingsModular Programming with PHP 7 Rating: 0 out of 5 stars0 ratingsLearning Bootstrap Rating: 1 out of 5 stars1/5Node.js High Performance Rating: 0 out of 5 stars0 ratingsApplication Development with Swift Rating: 0 out of 5 stars0 ratingsAngular 2 Components Rating: 0 out of 5 stars0 ratings
Programming For You
Python: Learn Python in 24 Hours Rating: 4 out of 5 stars4/5Python: For Beginners A Crash Course Guide To Learn Python in 1 Week Rating: 4 out of 5 stars4/5SQL: For Beginners: Your Guide To Easily Learn SQL Programming in 7 Days Rating: 5 out of 5 stars5/5Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Game Development with Unreal Engine 5: Learn the Basics of Game Development in Unreal Engine 5 (English Edition) Rating: 0 out of 5 stars0 ratingsHTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5Modern C++ for Absolute Beginners: A Friendly Introduction to C++ Programming Language and C++11 to C++20 Standards Rating: 0 out of 5 stars0 ratingsThe Unofficial Guide to Open Broadcaster Software: OBS: The World's Most Popular Free Live-Streaming Application Rating: 0 out of 5 stars0 ratingsCoding All-in-One For Dummies Rating: 4 out of 5 stars4/5SQL All-in-One For Dummies Rating: 3 out of 5 stars3/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5Python Projects for Beginners: A Ten-Week Bootcamp Approach to Python Programming Rating: 0 out of 5 stars0 ratingsLearn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 0 out of 5 stars0 ratingsLinux: Learn in 24 Hours Rating: 5 out of 5 stars5/5Web Designer's Idea Book, Volume 4: Inspiration from the Best Web Design Trends, Themes and Styles Rating: 4 out of 5 stars4/5Learn JavaScript in 24 Hours Rating: 3 out of 5 stars3/5PYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5
Reviews for Getting Started with React Native
3 ratings0 reviews
Book preview
Getting Started with React Native - Ethan Holmes
Table of Contents
Getting Started with React Native
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Exploring the Sample Application
Installing Xcode
Running the sample application
A sneak peek at the sample application
Experimenting with the sample application
Summary
2. Understanding React Native Fundamentals
The Virtual DOM
Components
Creating your first component
JSX
Back to our first component
Props and states
Props
Validating props
State
Summary
3. Beginning with the Example Application
Generating the projects
Xcode and the iOS simulator
The Android SDK and emulator
Modifying the React Native starter template
Structuring the application
Creating the SimpleButton component
Navigation
The Navigator component
Navigator.NavigationBar
The NoteScreen – first pass
Summary
4. Working with Styles and Layout
React CSS
Style Sheet
Styling the SimpleButton component
Layout and Flexbox
Flex container
Flex items
Horizontal and vertical centering
Absolute positioning
Styling the NavigationBar component
Changing the Android Material Theme
Styling the NoteScreen
Summary
5. Displaying and Saving Data
Lists
Understanding props
Using state
Passing callbacks in props
Creating new notes
Using AsyncStorage
Deleting notes
Summary
6. Working with Geolocation and Maps
Introducing the Geolocation API
The location permission in iOS
Tagging notes with geolocation
NoteLocationScreen
MapView
Summary
7. Integrating Native Modules
Adding images to notes
Installing react-native-camera on iOS
Searching for Native Modules
Using the camera component
Viewing images
The image component
Deleting images
Connecting the final pieces
Summary
8. Releasing the Application
Generating the static bundle in iOS
Testing the static bundle in iOS
Creating an iOS release in Xcode
Generating the Android APK
Summary
Index
Getting Started with React Native
Getting Started with React Native
Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: December 2015
Production reference: 1101215
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78588-518-1
www.packtpub.com
Credits
Authors
Ethan Holmes
Tom Bray
Reviewer
Soliury
Content Manager
Wilson Dsouza
Acquisition Editor
Aaron Lazar
Content Development Editor
Divij Kotian
Technical Editor
Naveenkumar Jain
Copy Editor
Sneha Singh
Project Coordinator
Nikhil Nair
Proofreader
Safis Editing
Indexer
Hemangini Bari
Graphics
Kirk D'Penha
Production Coordinator
Shantanu N. Zagade
Cover Work
Shantanu N. Zagade
About the Authors
Ethan Holmes is a Software Engineer from Vancouver, BC, Canada. He obtained a B.Sc. in computer science from Simon Fraser University. He has primarily been a full-stack web developer working and creating applications for start-ups in the Silicon Beach area. Currently, he is stationed at Cargomatic, disrupting the freight industry. After learning React for the web, learning React Native complemented the skills he obtained as a web developer and allowed him to quickly make the transition to mobile development.
You can follow him on Twitter at @sherclockholmes.
I'd like to thank Tom for being such a great ol' chap and for giving me the opportunity to work on this book with him. Big thanks to the friends and colleagues I have met throughout my many years of software development. Shout out to my Bengal cat, Whiskey!
Tom Bray has been developing for the web since the browser wars of the late 90s when DHTML was the buzzword of the day. Creating great user experiences using the cutting edge technologies of the day has always been his passion, from Flash to Flex to Adobe AIR to React, and React Native.
He has created sophisticated software that has been used by large companies, such as Adobe, MySpace, Cisco, Informatica, and Dell; it has been a key contributor to numerous start-ups where he has worn many hats and gained a broad skill set. He currently serves as the Principal Software Architect with Cargomatic where he has designed a system to orchestrate the movement of ocean freight to and from America's ports—a solution that leveraged React Native to assign work to truck drivers and track their progress.
You can follow him on Twitter at @tombray.
I would like to dedicate this book to my wonderful wife, Amy, and my amazing son, Tyler. They have put up with me working late at night and on weekends, and I couldn't have written this book without their love and support. They bring me great joy and I'm so grateful to have them in my life.
I also want to thank my co-author, Ethan Holmes, who is a fantastic developer, a great writer, and an exemplary Canadian. His hard work and dedication were crucial in making this book a reality in a short amount of time. Thank you, Ethan!
About the Reviewer
Soliury is a frontend engineer from China. He is now working in Meituan and he loves JavaScript. He is excited to see that React Native is getting more and more popular. He also writes react-native apps for http://cnodejs.org. His GitHub ID is https://github.com/soliury.
I would like to thank my girlfriend, Jennifer, who has supported my work and also understands me. I would also like to thank Nikhil for helping me when I am busy.
www.PacktPub.com
Support files, eBooks, discount offers, and more
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and, as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Free access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
Preface
Why are there so many alternatives to using native languages to write mobile apps? And, more importantly, why does the world need yet another approach? Obviously, there must be a problem that hasn't been solved.
Developers want to use just one language to develop for both iOS and Android. Web developers want to reuse their existing JavaScript knowledge and leverage the web frameworks they already know and love. This is why Apache Cordova (PhoneGap) exists. By wrapping a web browser in a native app, developers can package their HTML, CSS, and JavaScript applications in a native shell, but why aren't all mobile applications based on Cordova?
Users expect native performance, with a native user experience. Hybrid apps don't solve the user's problems, they solve the developer's problems. We need a technology that can do both!
React Native changes the game with applications that are truly native. It doesn't use a WebView or transpile JavaScript to native languages. Think of it as native UI components being controlled by a JavaScript brain. The result is a user experience that is indistinguishable