O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Learning React, 2nd Edition

Book Description

If you want to learn how to build efficient React applications, this is your book. Ideal for web developers and software engineers who understand how JavaScript, CSS, and HTML work in the browser, this updated edition provides best practices and patterns for writing modern React code. No prior knowledge of React or functional programming is necessary.

Authors Alex Banks and Eve Porcello show you how to create UIs that can deftly display changes without page reloads on large-scale data-driven websites. You’ll also discover how to work with functional programming and the latest ECMAScript features. Once you learn how to build React components with this hands-on guide, you’ll understand just how useful React can be in your organization.

  • Understand key functional programming concepts with JavaScript
  • Look under the hood to learn how React runs in the browser
  • Create application presentation layers with React components
  • Manage data and reduce the time you spend debugging applications
  • Explore React’s component lifecycle to improve UI performance
  • Use a routing solution for single-page application features
  • Learn how to structure React applications with servers in mind

Table of Contents

  1. Preface
    1. Conventions Used in This Book
    2. Using Code Examples
    3. O’Reilly Safari
    4. How to Contact Us
    5. Acknowledgments
  2. 1. Welcome to React
    1. A Strong Foundation
    2. React’s Past and Future
      1. Learning React: Second Edition Changes
    3. Working with the Files
      1. File Repository
      2. React Developer Tools
      3. Installing Node.js
  3. 2. JavaScript for React
    1. Declaring Variables
      1. The const Keyword
      2. The let Keyword
      3. Template Strings
    2. Creating Functions
      1. Function Declarations
      2. Function Expressions
      3. Default Parameters
      4. Arrow Functions
    3. Compiling JavaScript
    4. Objects and Arrays
      1. Destructuring Objects
      2. Destructuring Arrays
      3. Object Literal Enhancement
      4. The Spread Operator
    5. Asynchronous JavaScript
      1. Simple Promises with Fetch
      2. Async/Await
      3. Building Promises
    6. Classes
    7. ES6 Modules
      1. CommonJS
  4. 3. Functional Programming with JavaScript
    1. What It Means to Be Functional
    2. Imperative Versus Declarative
    3. Functional Concepts
      1. Immutability
      2. Pure Functions
      3. Data Transformations
      4. Higher-Order Functions
      5. Recursion
      6. Composition
      7. Putting It All Together
  5. 4. How React Works
    1. Page Setup
      1. HTML Document Setup with React
    2. React Elements
      1. React Elements
    3. ReactDOM
      1. Children
    4. React Components
      1. React Components: A Historical Tour
  6. 5. React with JSX
    1. React Elements as JSX
      1. JSX Tips
      2. Mapping Arrays with JSX
    2. Babel
    3. Recipes as JSX
    4. React Fragments
    5. Intro to webpack
      1. Creating the Project
      2. Loading the bundle
      3. Source mapping
      4. create-react-app
  7. 6. React State Management
    1. Building a Star Rating Component
    2. The useState Hook
    3. State in Component Trees
      1. Sending State Down a Component Tree
      2. Sending Interactions back up a Component Tree
    4. Building Forms
      1. Using Refs
      2. Controlled Components
      3. Creating Custom Hooks
      4. Adding Colors to State
    5. React Context
      1. Placing Colors in Context
      2. Retrieving Colors with useContext
      3. Stateful Context Providers
      4. Custom Hooks with Context