concept reselect in category react

This is an excerpt from Manning's book Redux in Action.
With redux-saga under your belt, you can confidently say you’ve got a handle on the messiest corners of Redux applications. You can move on to further optimizations elsewhere in the codebase by learning how to use selectors, such as reselect, in the next chapter.
Selectors are functions that accept a state from the Redux store and compute data that will eventually be passed as props to React. Selectors are often thought of in terms of the reselect library, which you’ll use later in the chapter, but any function that performs this role can be considered a selector. They’re pure functions, meaning they don’t produce any side effects. And like all pure functions, they’re easy to write and maintain. This also makes them easy to memoize, an optimization you can apply which will store the result of each computation based on the arguments passed into a selector. More on that later when we get to reselect.
Update getFilteredTasks to be a reselect selector using the createSelector function.
Next, let’s take a first look at how we’d use reselect. First, install the package:
npm install reselectIn the reducer, import the package, then create the getTasks and getSearchTerm selectors. Next, create a memoized getFilteredTasks selector via the createSelector function provided by reselect. This ensures that getFilteredTasks won’t recompute the list of tasks when it receives the same arguments, as shown in the following listing.
Listing 7.16. Creating new selectors – src/reducers/index.js
import { createSelector } from 'reselect'; #1 ... const getTasks = state => state.tasks.tasks; #2 const getSearchTerm = state => state.tasks.searchTerm; #3 export const getFilteredTasks = createSelector( #4 [getTasks, getSearchTerm], (tasks, searchTerm) => { return tasks.filter(task => task.title.match(new RegExp(searchTerm, 'i'))); }, ); #1 Imports createSelector, which creates a memoized selector #2 Adds a selector for tasks #3 Adds a selector for the search term #4 Changes getFilteredTasks to be a memoized selector !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":63},{\"line\":0,\"ch\":65}],[{\"line\":13,\"ch\":0},{\"line\":13,\"ch\":2}],[{\"line\":2,\"ch\":65},{\"line\":2,\"ch\":67}],[{\"line\":14,\"ch\":0},{\"line\":14,\"ch\":2}],[{\"line\":3,\"ch\":65},{\"line\":3,\"ch\":67}],[{\"line\":15,\"ch\":0},{\"line\":15,\"ch\":2}],[{\"line\":5,\"ch\":65},{\"line\":5,\"ch\":67}],[{\"line\":16,\"ch\":0},{\"line\":16,\"ch\":2}]]"} !@%STYLE%@!