Chapter 11. Structuring Redux code

 

This chapter covers

  • Understanding popular options for organizing Redux code
  • Scaling the structure of a Redux application

If you remember one thing from this chapter, let it be this: Redux couldn’t care less where you put its constituent parts. The package has a curious dynamic; Redux comes with a tiny API for storing and updating state, but it introduces a comprehensive design pattern into an application. Looking at the Redux architecture diagram, there are few methods provided by Redux to connect all the pieces. Figure 11.1 highlights the location of those methods. As you know, React Redux provides an important role in exposing some of that functionality to the web application.

Figure 11.1. With help from React Redux, Redux exposes a few methods for state management.

The takeaway here is that Redux doesn’t have any reason or ability to dictate how your code is structured. If an action object makes it back to the store, a Redux workflow is satisfied. Whatever mousetrap you build to facilitate this is completely up to you.

11.1. Rails-style pattern

11.2. Domain-style pattern

11.3. Ducks pattern

11.4. Selectors

11.5. Sagas

11.6. Styles

11.7. Tests

11.8. Exercise and solutions

Summary

sitemap