Complete the code to select the user name from the Redux state.
const userName = useSelector(state => state.user[1]name);The dot . operator accesses the name property of the user object in the Redux state.
Complete the code to create a selector function that returns the list of todos from state.
const selectTodos = state => state.[1];tasks or items.The selector accesses todos property directly from the state object.
Fix the error in the selector to get completed todos only.
const selectCompletedTodos = state => state.todos.filter(todo => todo.[1] === true);true.The property completed is the standard boolean flag for completed todos.
Fill both blanks to create a memoized selector using reselect.
import { createSelector } from 'reselect'; const selectTodos = state => state.todos; const selectCompletedTodos = createSelector( selectTodos, todos => todos.filter(todo => todo.[1] === [2]) );
createSelector correctly.The selector filters todos where completed is true using createSelector for memoization.
Fill both blanks to create a selector that returns the count of active todos.
const selectActiveTodoCount = createSelector( state => state.todos, todos => todos.filter(todo => !todo.[1]).[2] );
The selector filters todos where completed is false, then gets the length of that filtered array.