Book Image

React Design Patterns and Best Practices. - Second Edition

Book Image

React Design Patterns and Best Practices. - Second Edition

Overview of this book

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.
Table of Contents (19 chapters)
Free Chapter
1
Section 1: Hello React!
4
Section 2: How React works
9
Section 3: Performance, Improvements and Production!

To get the most out of this book

To master React, you need to have a fundamental knowledge of JavaScript and Node.js. This book is mostly targeting web developers, and, at the time of writing, the following assumptions were made of the reader:

  • The reader knows how to install the latest version of Node.js.
  • The reader is an intermediate developer who can understand JavaScript ES6 syntax.
  • Some experience of CLI tools and Node.js syntax is required.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/React-Design-Patterns-and-Best-Practices-Second-Edition. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/9781789530179_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Again, with createClass, we use a function, while, with the ES6 classes, we set an attribute of the instance."

A block of code is set as follows:

const Button = React.createClass({ 
getInitialState() {
return {
text: 'Click me!'
};
},
render() {
return <button>{this.state.text}</button>;
}
});

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

 React.createElement("img", { 
src: "https://www.dev.education/images/logo.png",
alt: "DEV Education"
});

Any command-line input or output is written as follows:

 npm install -g create-react-app

Bold: Indicates a new term, an important word, or words that you see on screen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Let's start with a basic example—displaying a form with an input field and a Submit button."

Warnings or important notes appear like this.
Tips and tricks appear like this.