Chapter 7. Preparing data for components

 

This chapter covers

  • Introducing selectors
  • Organizing state in the store
  • Using advanced selectors for deriving data
  • Memoizing selectors with reselect

Our task management application, Parsnip, has everything it needs to be a successful production application, but there are still several optimizations that can be made to make the code more performant, better organized, and more maintainable. In this chapter, we’ll explore selectors: functions used to compute derived data from the Redux store. Conveniently, the selector pattern manages to offer all three benefits.

Up to now, you’ve done a fine job of breaking down your code into manageable pieces by leveraging actions and reducers. Actions help model what is happening in the app; reducers allow you to apply updates to state in a centralized, testable way. Actions and reducers help in two more ways: they allow you to clean up your views (React components) by reducing the number of things the views are responsible for, and they help you decouple and modularize the different types of work happening in your application. Selectors may be slightly lesser known than actions and reducers, but as a software pattern, they offer similar benefits.

By the end of this chapter, you’ll be ready to wield selectors in the battle against bloated and non-reusable React components.

7.1. Decoupling Redux from React components

 
 

7.2. What are selectors?

 
 

7.3. Implementing search

 
 
 

7.4. Introducing reselect

 
 
 

7.5. Implementing reselect

 

7.6. Exercise

 

7.7. Solution

 
 
 

Summary

 
 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest