Book Description

React helps you create and work on an app in just a few minutes, but learning how to put all the pieces together is hard. How do you validate a form? Or implement a complex multistep user action without writing messy code? How do you test your code? Make it reusable? Wire it to a backend? Keep it easy to understand? The React Cookbook delivers answers fast.

Many books teach you how to get started, understand the framework, or use a component library with React, but very few provide examples to help you solve particular problems. This easy-to-use cookbook includes the example code developers need to unravel the most common problems when using React, categorized by topic area and problem.

You’ll learn how to:

  • Create a single-page application in React using a rich UI
  • Structure code that can be worked on by large teams
  • Integrate with backend services such as REST and GraphQL
  • Use offline caching with technologies such as Redux or MobX
  • Secure applications with technologies such as OAuth
  • Deal with bugs and avoid common functional and performance problems

Table of Contents

  1. Preface
    1. Conventions Used in This Book
    2. Using Code Examples
    3. O’Reilly Online Learning
    4. How to Contact Us
  2. 1. Creating Applications
    1. 1.1. Create a Vanilla App with create-react-app
    2. 1.2. Build Content-Rich Apps with Gatsby
    3. 1.3. Build Universal Apps with Razzle
    4. 1.4. Manage Server and Client Code with Next.js
    5. 1.5. Create a Tiny App with Preact
    6. 1.6. Build Libraries with NWB
    7. 1.7. Add React to Rails with Webpacker
    8. 1.8. Create Custom Elements with Preact
    9. 1.9. Use Storybook for Component Development
    10. 1.10. Test Your Code in a Browser with Cypress
  3. 2. Routing
    1. 2.1. Create Desktop/Mobile Interfaces with Responsive Routes
    2. 2.2. Move State into Routes to Create Deep Links
    3. 2.3. Use MemoryRouter for Unit Testing
    4. 2.4. Use Prompt for Page Exit Confirmations
    5. 2.5. Add Page Transitions With react-transition-group
    6. 2.6. Create Secured Routes