September 2018
Intermediate to advanced
302 pages
7h 17m
English
To cache the selector, we will use the memoization function. Such a function recomputes the value once the function's input reference changes. To save us time, we will use a popular library that implements this memoization function for us. The library is called reselect. In reselect, the reference change is checked with strong equality (===), but you can change the equality function to your own if you need. Add the library with the following command:
yarn add reselect
With that, we are ready to cache:
// src/Chapter 8/Example 2/src/features/// ./tasks/state/selectors/tasks.jsimport { createSelector } from 'reselect';export const tasksSelector = state => state.tasks;export const tasksEntitiesSelector = createSelector( ...
Read now
Unlock full access