react_native_cookbook_lebensold.pdf

(10397 KB) Pobierz
React Native
Cookbook
BRINGING THE WEB TO NATIVE PLATFORMS
Jonathan Lebensold
Bringing the Web to Native Platforms
React Native Cookbook
Jonathan Lebensold
React Native Cookbook
by Jonathan Lebensold
Copyright © 2018 Paradem Consulting. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are
also available for most titles (http://oreilly.com/safari). For more information, contact our corporate/insti‐
tutional sales department: 800-998-9938 or
corporate@oreilly.com.
Editors:
Nan Barber and Meg Foley
Production Editor:
Kristen Brown
Copyeditor:
Kim Cofer
Proofreader:
Christina Edwards
March 2018:
First Edition
Indexer:
Judith McConville
Interior Designer:
David Futato
Cover Designer:
Karen Montgomery
Illustrator:
Rebecca Demarest
Revision History for the First Edition
2018-02-13:
First Release
See
http://oreilly.com/catalog/errata.csp?isbn=9781491993842
for release details.
The O’Reilly logo is a registered trademark of O’Reilly Media, Inc.
React Native Cookbook,
the cover
image, and related trade dress are trademarks of O’Reilly Media, Inc.
While the publisher and the author have used good faith efforts to ensure that the information and
instructions contained in this work are accurate, the publisher and the author disclaim all responsibility
for errors or omissions, including without limitation responsibility for damages resulting from the use of
or reliance on this work. Use of the information and instructions contained in this work is at your own
risk. If any code samples or other technology this work contains or describes is subject to open source
licenses or the intellectual property rights of others, it is your responsibility to ensure that your use
thereof complies with such licenses and/or rights.
978-1-491-99384-2
[LSI]
Table of Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
1. The React Native Toolchain. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Setting Up Your Development Environment
1.2 Writing ES6 with Babel
1.3 Organizing Project Files
1.4 Dealing with Catastrophic Failure
1
4
7
14
19
23
30
37
47
63
66
69
76
79
88
93
95
2. Living in the React Native Ecosystem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.1 Stop Repeating Yourself: Implement Custom Components
2.2 Adding an Open Source Progress Bar
2.3 Sharing Custom Components
2.4 Routing Between Login Screens
2.5 Using Redux for Global State Management in Redux
3.1 Composing Stylesheets
3.2 Building Flexible Layouts with Flexbox
3.3 Importing Image Vectors and Icons
3.4 Looping Animations
3. Style and Design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4. Managing Hardware Platforms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
4.1 Asking for Permission to Use Device Hardware (iOS)
4.2 Fetching Paginated Requests
4.3 Save Application State with Redux and Local Storage
4.4 Using the Filesystem
iii
Zgłoś jeśli naruszono regulamin