About this book

Redux is a state management library, designed to make building complicated user interfaces easier. It’s most commonly used with React, which we pair it with in this book, but it’s also becoming popular with other front end libraries such as Angular.

In 2015, the React ecosystem sorely needed Redux to come along. Predating Redux, the Flux architecture pattern was an exciting breakthrough, and React developers around the world tried their hand at an implementation. Dozens of libraries received noteworthy attention and use. Eventually, the excitement gave way to exhaustion. The number of choices for managing state in a React application was overwhelming.

Redux immediately started to pick up steam after its release, and soon became the most recommended Flux-inspired library. Its use of a single store, focus on immutability, and amazing developer experience proved Redux to be a more simple, elegant, and intuitive solution to most of the issues facing existing Flux libraries. You still have several options for managing state in complex applications, but for those who prefer a Flux-like pattern, Redux has become the default.

This book will walk you through the fundamentals of Redux before moving on to explore the powerful developer tools. Together, we’ll work step-by-step through a task-management application, where we’ll explore real-world Redux usage with a focus on best practices. Finally, we’ll circle back to testing strategies and the various conventions for structuring your applications.

Who should read this book

Readers should be comfortable with JavaScript (including ES2015) and have at least basic proficiency with React. We understand, though, that many developers end up getting thrown into Redux at approximately the same moment they’re being introduced to React. We’ve tried our best to accommodate those in this category, and we believe they can make their way through this book with a little extra effort. However, our official recommendation is to gain a strong foundation in React prior to reading this book. If you haven’t done any React development, consider the Manning titles React Quickly (https://www.manning.com/books/react-quickly) or React in Action (https://www.manning.com/books/react-in-action).

How this book is organized: a roadmap

This book includes 12 chapters and an appendix.

Chapter 1 introduces the landscape that Redux was born into and why it was created. You’ll learn what Redux is, what it’s used for, and when not to use it. The chapter wraps up with several state management alternatives to Redux.

Chapter 2 jumps headlong into your first React and Redux application. It’s a whirlwind tour of a typical workflow used to create new features. You’ll get a good high-level view of each of the actors involved: actions, reducers, the store, and so on.

Chapter 3 takes a step back to introduce the high-powered Redux DevTools. The developer tools are one of the biggest selling points for using Redux, and this chapter demonstrates why.

Chapter 4 finally introduces side effects to the example started in chapter 2. You’ll set up a local server and handle API requests within the Redux pattern.

Chapter 5 dives into a more advanced feature: middleware. You’ll learn where middleware sits in the stack, what it’s capable of, and how to build custom middleware of your own.

Chapter 6 explores an advanced pattern for handling more complex side effects. You’ll learn how to leverage ES6 generator functions; then you’ll learn how to use sagas to manage long-running processes.

Chapter 7 puts the spotlight on the connection between the Redux store and your views. You’ll learn how selector functions work, then implement a robust solution using the reselect library.

Chapter 8 addresses the common question as to how best to structure data in a Redux store. You’ll reflect on the strategy used up to this point in the book, then explore an alternative approach: normalization.

Chapter 9 circles back to cover all things testing. You’ll learn about popular testing tools such as Jest and Enzyme, as well as strategies for testing Redux actions, reducers, selectors, and much more.

Chapter 10 is all about keeping your application lean and mean. It covers performance profiling tools, React best practices, and Redux-specific strategies for boosting performance.

Chapter 11 covers several strategies for organizing your Redux application. Redux doesn’t mind where you put things, so you’ll learn popular conventions that have been established.

Chapter 12 reminds you that Redux can manage the state of more than a React web application. You’ll get a quick tour of the role Redux can play in mobile, desktop, and other web application environments.

The appendix provides instructions for environment setup and tool installation. The book will direct you to the appendix at appropriate points.

About the code

Most of the code examples are for Parsnip, the book’s example application. These examples are included as numbered listings, many of which are annotated to provide clarity and reasoning behind certain code choices. Code examples directly in the text can be identified by a fixed-width typeface, like this.

Source code for the examples in the book can be downloaded from the publisher’s website at https://www.manning.com/books/redux-in-action or at https://github.com/wfro/parsnip.

One-step install scripts are available for OSX, Linux, and Windows, and are available along with the rest of the book’s source code. See the appendix for instructions on getting started.

Software requirements

Most of the code examples, especially those related to the example application, require a web browser. We recommend Chrome, which will work seamlessly with React and Redux developer tools.

We bootstrapped the example application with create-react-app, which isn’t strictly required, but highly recommended. It’s the most painless way to set up a modern React development environment.

We used the following Create React App and Redux versions:

  • Redux: 3.7.2
  • Create React App: 1.0.17

Book forum

Purchase of Redux in Action includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the authors and from other users. To access the forum, go to https://forums.manning.com/forums/redux-in-action. You can also learn more about Manning’s forums and the rules of conduct at https://forums.manning.com/forums/about.

Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the authors can take place. It isn’t a commitment to any specific amount of participation on the part of the authors, whose contribution to the forum remains voluntary (and unpaid). We suggest you try asking the authors challenging questions lest their interest stray! The forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.

Other online resources

The Redux community is incredibly active on several different platforms. We recommend all the following resources to learn more, help solidify concepts, and ask questions:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.61.170