Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Selectors | Fundamental Concepts
Introduction to Redux

bookSelectors

Selectors are custom functions that extract specific values or pieces of information from a store's state value. As the state value grows and size and complexity, the selector functions can be useful in extracting relevant information.

A simple example is as follows:

// Consider that state has a dictionary of posts identified by ids, and each post object has a 'date' key
// We create a selector called 'selectPostDate', which extracts the post date based on 'id'

let selectPostDate = (state, id) => state.posts[id].date;

const postDate = selectPostDate(store.getState());
console.log(postDate);
// 6 Nov 2023
question mark

Why are selectors useful?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 5

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Suggested prompts:

Ask me questions about this topic

Summarize this chapter

Show real-world examples

Awesome!

Completion rate improved to 3.45

bookSelectors

Swipe to show menu

Selectors are custom functions that extract specific values or pieces of information from a store's state value. As the state value grows and size and complexity, the selector functions can be useful in extracting relevant information.

A simple example is as follows:

// Consider that state has a dictionary of posts identified by ids, and each post object has a 'date' key
// We create a selector called 'selectPostDate', which extracts the post date based on 'id'

let selectPostDate = (state, id) => state.posts[id].date;

const postDate = selectPostDate(store.getState());
console.log(postDate);
// 6 Nov 2023
question mark

Why are selectors useful?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 5
some-alt