Selectors
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
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 2. Capítulo 5
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Awesome!
Completion rate improved to 3.45
Selectors
Desliza para mostrar el menú
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
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 2. Capítulo 5