0%

Book Description

Build modular React web apps that are scalable, maintainable and powerful using design patterns and insightful practices

Key Features

  • Get familiar with design patterns in React like Render props and Controlled/uncontrolled inputs
  • Learn about class/ functional, style and high order components with React
  • Work through examples that can be used to create reusable code and extensible designs

Book Description

React is an adaptable JavaScript library for building complex UIs from small, detached bits called components. This book is designed to take you through the most valuable design patterns in React, helping you learn how to apply design patterns and best practices in real-life situations.

You'll get started by understanding the internals of React, in addition to covering Babel 7 and Create React App 2.0, which will help you write clean and maintainable code. To build on your skills, you will focus on concepts such as class components, stateless components, and pure components. You'll learn about new React features, such as the context API and React Hooks that will enable you to build components, which will be reusable across your applications. The book will then provide insights into the techniques of styling React components and optimizing them to make applications faster and more responsive. In the concluding chapters, you'll discover ways to write tests more effectively and learn how to contribute to React and its ecosystem.

By the end of this book, you will be equipped with the skills you need to tackle any developmental setbacks when working with React. You'll be able to make your applications more flexible, efficient, and easy to maintain, thereby giving your workflow a boost when it comes to speed, without reducing quality.

What you will learn

  • Get familiar with the new React features,like context API and React Hooks
  • Learn the techniques of styling and optimizing React components
  • Make components communicate with each other by applying consolidate patterns
  • Use server-side rendering to make applications load faster
  • Write a comprehensive set of tests to create robust and maintainable code
  • Build high-performing applications by optimizing components

Who this book is for

This book is for web developers who want to increase their understanding of React and apply it to real-life application development. Prior experience with React and JavaScript is assumed.

Table of Contents

  1. Title Page
  2. About Packt
    1. Why subscribe?
    2. Packt.com
  3. Copyright and Credits
    1. React Design Patterns and Best Practices Second Edition
  4. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Section 1: Hello React!
  7. Taking Your First Steps with React
    1. Declarative programming
    2. React elements
    3. Unlearning everything
    4. Common misconceptions
    5. Summary
  8. Clean Up Your Code
    1. JSX
      1. Babel 7
      2. Hello, World!
      3. DOM elements and React components
      4. Props
      5. Children
      6. Differences with HTML
        1. Attributes
        2. Style
        3. Root
        4. Spaces
        5. Boolean attributes
      7. Spread attributes
      8. JavaScript templating
      9. Common patterns
        1. Multi-line
        2. Multi-properties
        3. Conditionals
        4. Loops
        5. Control statements
        6. Sub-rendering
    2. Code style
      1. EditorConfig
        1. Configuring EditorConfig
      2. ESLint
        1. Installation
        2. Configuration
        3. Git hooks
        4. React plugin
        5. Airbnb React/JSX style guide
    3. The basics of functional programming
      1. First-class objects
      2. Purity
      3. Immutability
      4. Currying
      5. Composition
      6. FP and user interfaces
    4. Summary
  9. Section 2: How React works
  10. Creating Truly Reusable Components
    1. Creating classes
      1. The createClass factory
      2. Extending React.Component
      3. The main differences
        1. Props
        2. State
        3. Autobinding
      4. Stateless components
        1. Props and context
        2. The this keyword
        3. State
        4. Life cycle 
        5. Refs and event handlers
        6. Optimization
        7. Layout components
    2. The state
      1. External libraries
      2. How it works
      3. Asynchronous
      4. Using the state
        1. Derivables
        2. The render method
    3. React hooks
    4. Prop types
      1. React Docgen
    5. Reusable components
    6. Fragments
    7. Summary
  11. Compose All the Things
    1. Communication between components
      1. Children
    2. The container and presentational pattern
    3. Mixins
    4. Higher order components
    5. Recompose
      1. Context
    6. FunctionAsChild
    7. Summary
  12. Proper Data Fetching
    1. Data flow
      1. Child-parent communication (callbacks)
      2. Common parent
    2. Data fetching
    3. React-refetch
    4. Context API
    5. Summary
  13. Write Code for the Browser
    1. Forms
      1. Uncontrolled components
      2. Controlled components
      3. JSON schema
    2. Handling events
    3. Refs
    4. Animations
      1. React motion
    5. Scalable Vector Graphics
    6. Summary
  14. Section 3: Performance, Improvements and Production!
  15. Make Your Components Look Beautiful
    1. CSS in JavaScript
    2. Inline styles
    3. Radium
    4. CSS modules
      1. Webpack 4
      2. Setting up a project
      3. Locally scoped CSS
      4. Atomic CSS modules
      5. React CSS modules
    5. Styled components
    6. Summary
  16. Server-Side Rendering for Fun and Profit
    1. Universal applications
    2. Reasons to implement SSR
      1. SEO
      2. A common code base
      3. Better performance
      4. Don't underestimate the complexity
    3. A basic example
    4. A data fetching example
    5. Next.js
    6. Summary
  17. Improve the Performance of Your Applications
    1. Reconciliation
    2. Keys
    3. Optimization techniques
      1. shouldComponentUpdate
      2. Stateless functional components
    4. Common solutions
      1. Why did you update?
      2. Creating functions inside the render method
      3. Constants props
      4. Refactoring and good design
    5. Tools and libraries
      1. Immutability
      2. Babel plugins
    6. Summary
  18. About Testing and Debugging
    1. The benefits of testing
    2. Painless JavaScript testing with Jest
    3. Testing events
    4. React DevTools
    5. Redux DevTools
    6. Summary
  19. React Router
    1. Installation and configuration
    2. Creating our sections
    3. Adding parameters to the routes
    4. Summary
  20. Anti-Patterns to be Avoided
    1. Initializing the state using properties
    2. Mutating the state
    3. Using indexes as a key
    4. Spreading properties on DOM elements
    5. Summary
  21. Deploying to Production
    1. Creating our first Digital Ocean Droplet
      1. Signing up to Digital Ocean
      2. Creating our first Droplet
      3. Installing Node.js
      4. Configuring Git and GitHub
      5. Turning off our droplet
    2. Configuring nginx, PM2, and a domain
      1. Installing and configuring nginx
      2. Setting up a reverse proxy server
      3. Adding a domain to our droplet
    3. Implementing CircleCI for continuous integration
      1. Adding an SSH key to CircleCI
      2. Configuring CircleCI
      3. Creating ENV variables in CircleCI
    4. Summary
  22. Next Steps
    1. Contributing to React
    2. Distributing your code
    3. Publishing an npm package
    4. Summary
  23. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think
3.21.233.41