About This E-Book EPUB is an open, industry-standard format for e-books However, support for EPUB and its many features varies across reading devices and applications Use your device or app settings to customize the presentation to your liking Settings that you can customize often include font, font size, single or double column, landscape or portrait mode, and figures that you can click or tap to enlarge For additional information about the settings and features on your reading device or app, visit the device manufacturer’s Web site Many titles include programming code or configuration examples To optimize the presentation of these elements, view the e-book in single-column, landscape mode and adjust the font size to the smallest setting In addition to presenting code and configurations in the reflowable text format, we have included images of the code that mimic the presentation found in the print book; therefore, where the reflowable format may compromise the presentation of the code listing, you will see a “Click here to view code image” link Click the link to view the print-fidelity code image To return to the previous page viewed, click the Back button on your device or app Learning React Second Edition Kirupa Chinnathambi Learning React, Second Edition Copyright © 2018 by Pearson Education, Inc All rights reserved No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher No patent liability is assumed with respect to the use of the information contained herein Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions Nor is any liability assumed for damages resulting from the use of the information contained herein ISBN-13: 978-0-13-484355-1 ISBN-10: 0-13-484355-X Library of Congress Control Number: 2017957370 18 Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized Pearson cannot attest to the accuracy of this information Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark Warning and Disclaimer Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied The information provided is on an “as is” basis The author and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book Special Sales For information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic versions; custom cover designs; and content particular to your business, training goals, marketing focus, or branding interests), please contact our corporate sales department at corpsales@pearsoned.com or (800) 382-3419 For government sales inquiries, please contact governmentsales@pearsoned.com For questions about sales outside the U.S., please contact intlcs@pearson.com Editor Mark Taber Managing Editor Sandra Schroeder Project Editor Mandie Frank Copy Editor Krista Hansing Indexer Erika Millen Proofreader Jeanine Furino Technical Editor Trevor McCauley Editorial Assistant Vanessa Evans Designer Chuti Prasertsith Compositor codemantra Accessing the Free Web Edition Your purchase of this book in any format includes access to the corresponding Web Edition, which provides several special online-only features: The complete text of the book Updates and corrections as they become available The Web Edition can be viewed on all types of computers and mobile devices with any modern web browser that supports HTML5 To get access to the Learning React Web Edition, all you need to is register this book: Go to www.informit.com/register Sign in or create a new account Enter the ISBN: 9780134843551 Answer the questions as proof of purchase The Web Edition will appear under the Digital Purchases tab on your Account page Click the Launch link to access the product To my dad! (Who always believed in me—even if what I was often doing made no sense to him or to me for that matter! ) Contents at a Glance Introducing React Building Your First React App Components in React Styling in React Creating Complex Components Transferring Properties Meet JSX…Again! Dealing with State in React Going from Data to UI in React 10 Events in React 11 The Component Lifecycle 12 Accessing DOM Elements in React 13 Setting Up Your React Dev Environment Easily 14 Working with External Data in React 15 Building an Awesome Todo List App in React 16 Creating a Sliding Menu in React 17 Avoiding Unnecessary Renders in React 18 Creating a Single-Page App in React Using React Router 19 Introduction to Redux 20 Using Redux with React Index ... Stuff Conclusion 20 Using Redux with React Managing React State with Redux How Redux and React Overlap Getting Started Building the App Conclusion Index About the Author Kirupa Chinnathambi has spent... State Change Optional: The Full Code Conclusion Going from Data to UI in React The Example Your JSX Can Be Anywhere, Part II Dealing with Arrays Conclusion 10 Events in React Listening and Reacting... on your device or app Learning React Second Edition Kirupa Chinnathambi Learning React, Second Edition Copyright © 2018 by Pearson Education, Inc All rights reserved No part of this book shall